UPDATE table
SET field = REPLACE(your_field, 'original_string', 'replace_string')
WHERE your_field LIKE '%original_string%'
有没有办法用JOOQ执行上面的查询?
答案 0 :(得分:3)
是的,它几乎翻译成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.*;