例如如下查询
UPDATE some_table
SET some_table.foo = other_table.bar
FROM other_table
WHERE some_table.id = other_table.id
我已经看过the documentation for the update statement in jOOQ,但找不到使用FROM ...
子句的示例。
答案 0 :(得分:2)
手册中确实缺少此功能。 I've created a bug report for this。但是,可以从API中获得它,并在Javadoc中进行了说明。只需在期望的位置添加FROM
子句:在UpdateFromStep.from()
ctx.update(SOME_TABLE)
.set(SOME_TABLE.FOO, OTHER_TABLE.BAR)
.from(OTHER_TABLE)
.where(SOME_TABLE.ID.eq(OTHER_TABLE.ID))
.execute();