jOOQ - multi-field for insertion

旧街凉风 提交于 2019-12-06 07:20:07

I'm not sure if this is possible with any SQL dialect in the first place, via INSERT .. VALUES, but you can certainly express that sort of query using INSERT .. SELECT:

INSERT INTO a (a, b, x, y, z)
SELECT a, b, ... other value ..., ... other value ..., ... other value ...
FROM b
WHERE ...
RETURNING *;

Or with jOOQ

context.insertInto(TABLE A, ... columns ...)
       .select(
           select(
               FIELD A, 
               FIELD B,
               ... other field of table A ...,
               ... other field of table A ...,
               ... other field of table A ...)
          .from(B)
          .where(...))
       )
       .returning()
       .fetch()
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!