Skip to content Skip to sidebar Skip to footer

Insert .. Select With Some Default Values In Mysql With Jooq

Lets say I have a table Person(id, fname, lname) and it contains a record (1, 'Michael', 'Bay'). Now I wish to create another record in Person table with the same fname and lname b

Solution 1:

jooq.insertInto(PERSON)
    .columns(PERSON.ID, PERSON.FNAME, PERSON.LNAME)
    .select(select(val(452452), PERSON.FNAME, PERSON.LNAME)
           .from(PERSON)
           .where(PERSON.ID.eq(1)))
    .execute();

As always, this is assuming the following static import:

import static org.jooq.impl.DSL.*;

Post a Comment for "Insert .. Select With Some Default Values In Mysql With Jooq"