我必须使用QueryDSL编写此查询:
select *
from table
where(field1, field2) in (
select inner_field_1, inner_field2
from ...
);
但是,我不知道如何在QueryDSL中将两个字段(field1和field2)与“ in”运算符一起使用。我一直在文档中寻找它,但是还没有看到两个字段的任何示例。
这是我到目前为止的内容:
Expression<?>[] projection = {
table.field1,
table.field2
};
SQLSubQuery outterQuery= new SQLSubQuery()
.from(table)
.where([some expression].in(inneryQuery.list(projection))) // ???
.groupBy(contentcache1.programId, contentcache1.id);
任何帮助,将不胜感激
提前非常感谢你
您可以将原始查询重写为:
select *
from table, (select distinct inner_field_1, inner_field2 from ...) subquery
where field1 = subquery.field1 and field2 = subquery.field2
然后,您不必使用IN
运算符。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句