James Hiew
James Hiew

Reputation: 7117

How do you do an `UPDATE ... FROM ...` query in jOOQ?

e.g. a query like the below

UPDATE some_table
SET some_table.foo = other_table.bar
FROM other_table
WHERE some_table.id = other_table.id

I already looked at the documentation for the update statement in jOOQ but could not find an example using a FROM ... clause.

Upvotes: 4

Views: 1067

Answers (1)

Lukas Eder
Lukas Eder

Reputation: 220877

This feature is indeed missing from the manual. I've created a bug report for this. However, it is available from the API and documented in the Javadoc. Just add the FROM clause where you'd expect it to be: In 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();

Upvotes: 4

Related Questions