【发布时间】:2021-03-30 15:29:42
【问题描述】:
如何编写 JOOQ 删除查询以加入来自 with 子句的字段?有可能吗?
我有一个正在运行的 SQL 查询,但我不知道如何将其转换为 JOOQ。
这是我的查询:
with "temp" as (
select field1 as field1
from "table"
join ("table2")
on (table.field1 = table2.field2)
)
delete from table using temp
where table.field1 = temp.field1;
我试过了:
transactionDSLContext.with("temp")
dsl.as(
select(TABLE.FIELD1.as("field1"))
.from(TABLE)
.join(TABLE2)
.on(TABLE.FIELD1.eq(TABLE2.FIELD2))
)
.delete(TABLE)
.where(TABLE.FIELD1.eq((Field<String>) temp.field("field1"))
.execute();
但我得到了:
ERROR: missing FROM-clause entry for table "temp"
【问题讨论】:
标签: postgresql sql-delete jooq