我在我的应用程序中使用 queryDsl 进行复杂的搜索查询。我是querydsl的新手。我从下面的代码开始从一个表(TableA)中获取几行。但我必须在其他表(TableB)中找到具有相同 ID 的人员(计数)列表
public static Predicate find(final Long pId)
QPerson qPerson = QPerson.person;
Predicate predicate;
BooleanBuilder booleanBuilder = new BooleanBuilder();
if (pId != null) {
booleanBuilder.or(qPerson.person_no.eq(pId));
}
if (name != null && !name.isEmpty()) {
booleanBuilder.or(qPerson.expiry_dt.eq(name));
}
predicate = booleanBuilder.getValue();
return predicate;
}
表A:
pId name
1001 sampleNameA
1002 sampleNameB
1003 sampleNameC
表B:
pId name interests
1001 sampleNameA music
1001 sampleNameA dance
1001 sampleNameA coding
1003 sampleNameC music
1002 sampleNameB dance
1002 sampleNameB coding
我需要通过以下查询获得这样的输出
select cnt cnt, tableA.* from master_person_table tableA,(select count(*) cnt from tableB WHERE pId = '1002') cnt WHERE pId = '1002'
输出:
count pId name
2 1002 sampleNameB
我需要在我的 HTML 中显示行数(对于 id=1002)。
谁能帮我找到要从 tableB 中获取的 pId 的计数
提前致谢