Search code examples
databasejooq

Jooq query to fetch data that are updated in last two days


I have been using student table which has field called updated_time which stores time in milliseconds.I have to fetch the student record that are updated in last two days using JOOQ query .what is the query for it?


Solution

  • ctx.selectFrom(STUDENT)
       .where(STUDENT.UPDATED_TIME.ge(currentTimestamp().minus(2)))
       .fetch();
    

    This assumes, as always with jOOQ, that you have the following static imports:

    import static com.example.mygeneratedtables.Tables.*;
    import static org.jooq.impl.DSL.*;