普通多表查询语句:

SELECT n0.*,t0.* FROM T_NAME n0,T_TITLE t0 WHERE  n0.ID = t0.SID
IMultiQuery multiQuery = new MultiQueryImpl();
AliasTable nameTable = multiQuery.table(Name.class);
AliasTable titleTable = multiQuery.table(Title.class);
multiQuery.whereEqual(nameTable.c(Name.T_ID), titleTable.c(Title.T_SID));

multiQuery.createQuery(Map.class,
        nameTable.c(Expression.EXPRESSION_ALL),
        titleTable.c(Expression.EXPRESSION_ALL));
List<Map> list = nameService.query(multiQuery);
System.out.println("---------------defeult select----------");
for(Map map : list) {
    System.out.println(map);
}

  查询结果:

            

      内连接查询语句:

SELECT n0.*,t0.* FROM T_NAME n0 INNER JOIN T_TITLE t0 ON  n0.ID = t0.SID
IMultiQuery multiQuery = new MultiQueryImpl();
AliasTable nameTable = multiQuery.table(Name.class);
AliasTable titleTable = multiQuery.join(Title.class);
multiQuery.join(
        new Join(titleTable, JoinType.INNER_JOIN).
        on(nameTable.c(Name.T_ID), titleTable.c(Title.T_SID)));
multiQuery.createQuery(Map.class,
        nameTable.c(Expression.EXPRESSION_ALL),
        titleTable.c(Expression.EXPRESSION_ALL));
List<Map> list = nameService.query(multiQuery);
System.out.println("---------------inner join----------");
for(Map map : list) {
    System.out.println(map);
}

      查询结果:

    

目录
Copyright © objectsql.com 2021 闽ICP备17009107号-3

闽公网安备 35020302035600号