EXISTS
Creates an EXISTS expression to check for the existence of rows in a subquery.
This function generates a SQL EXISTS (SELECT ...) clause. It evaluates to true if the subquery returns one or more rows, and false otherwise. It is a highly efficient way to check for related data without needing to retrieve the data itself. The subquery can be any valid SELECT statement, often a correlated subquery.
Example
// Find all artists who have at least one album.
// Generates: EXISTS (SELECT "Artist"."Name" FROM "Album" WHERE "Album"."ArtistId" = "Artist"."ArtistId")
select(Artists.name)
.from(Artists)
.where {
EXISTS(
Album
.select(Artists.name)
.where { Album.artistId EQ Artists.id }
)
}.execute()Content copied to clipboard
Return
An Expression representing the EXISTS condition.
Author
MOHAMMAD AZIM ANSARI
Parameters
select Statement
The subquery to check for row existence.