【发布时间】:2017-11-22 12:13:29
【问题描述】:
UPDATE table
SET field = REPLACE(your_field, 'original_string', 'replace_string')
WHERE your_field LIKE '%original_string%'
有没有办法可以使用 JOOQ 执行上述查询?
【问题讨论】:
UPDATE table
SET field = REPLACE(your_field, 'original_string', 'replace_string')
WHERE your_field LIKE '%original_string%'
有没有办法可以使用 JOOQ 执行上述查询?
【问题讨论】:
是的,它几乎可以 1:1 翻译。就这样写吧:
using(configuration)
.update(TABLE)
.set(TABLE.FIELD,
replace(TABLE.YOUR_FIELD, "original_string", "replace_string"))
.where(TABLE.YOUR_FIELD.like("%original_string%"))
.execute();
DSL.replace() method is documented in the Javadoc
import static org.jooq.impl.DSL.*;
import static com.example.your.schema.Tables.*;
【讨论】: