如何在 JOOQ 中编写多字段"in"谓词?



在JOOQ中,我可以像下面SQL一样编写代码吗?

我不知道如何编写具有多字段in谓词。

select some_value
from t1
where (t1.id1, t1.id2) in ((1, 2), (1, 3), (2, 1))

您正在寻找DSL.row()构造函数。另请参阅: https://www.jooq.org/doc/latest/manual/sql-building/conditional-expressions/in-predicate-degree-n

在您的情况下,请写:

DSL.using(configuration)
.select(T1.SOME_VALUE)
.from(T1)
.where(row(T1.ID1, T1.ID2).in(row(1, 2), row(1, 3), row(2, 1)))
.fetch();

一如既往:

// This static import is implied
import static org.jooq.impl.DSL.*;

最新更新