user2814395
user2814395

Reputation:

Jooq AddCondition method with Select Query

Here is my problem I am trying to add a Select query in where condition how can i achieve this in Jooq?

selectQuery.addFrom(DefaultInfo.DEFAULT_INFO);
selectQuery.addConditions(DefaultInfo.DEFAULT_INFO.FOLDER_TYPE=+"(Select FolderType From Folder Where Folder.FolderRSN = folderRSN )" );

I know this is wrong but how to add a Select Query output in another query where condition?

Upvotes: 3

Views: 952

Answers (1)

Lukas Eder
Lukas Eder

Reputation: 221195

Use the Field.in(Select<? extends Record1<T>>) method on your column. For example:

DEFAULT_INFO.FOLDER_TYPE.in(
    select(FOLDER.FOLDER_TYPE)
   .from(FOLDER)
   .where(FOLDER.FOLDER_RSN.eq("folderRSN"))
)

The IN predicate is documented in the manual, here:

Upvotes: 2

Related Questions