jOOQ - 从psql查询构建UPDATE

时间:2018-02-03 18:01:45

标签: java postgresql jooq

如何构建以下PSQL查询以使用jOOQ 3.10.x更新多个记录?

UPDATE users 
SET name = s.name, city = s.city 
FROM users_staging s
WHERE users.id = s.id;

1 个答案:

答案 0 :(得分:1)

UsersStaging s = USERS_STAGING.as("s");

DSL.using(configuration)
   .update(USERS)
   .set(USERS.NAME, s.NAME)
   .set(USERS.CITY, s.CITY)
   .from(s)
   .where(USERS.ID.eq(s.ID))
   .execute();