on
Same as calling on(left, right, JoinOp.EQ, null, null)
abstract fun <C> on(left: KQLiteColumn<C>, right: KQLiteColumn<C>, joinOp: JoinOp = JoinOp.EQ, and: Clause.() -> Unit? = null, or: Clause.() -> Unit? = null): SelectStatement<T>
Specifies the ON condition for a JOIN clause.
This function defines how two tables are related in a join operation by comparing columns. It supports standard comparison operators and allows for additional AND or OR conditions.
Example (Inner Join)
// SELECT * FROM Artists
// INNER JOIN Albums ON Artists.artistId = Albums.artistId
Artists
.select()
.join(Albums, JoinType.INNER_JOIN)
.on(Artists.artistId, Albums.artistId)
.execute()Content copied to clipboard
Example (Inner Join with additional AND condition)
// Example with an additional AND condition
// SELECT * FROM Artists
// INNER JOIN Albums ON Artists.artistId = Albums.artistId AND Albums.year > 2000
Artists
.select()
.join(Albums, JoinType.INNER_JOIN)
.on(
Artists.artistId,
Albums.artistId,
and = {
Albums.year GT 2000
},
).execute()Content copied to clipboard
Example (Join with < operator)
Artists
.select(Artists.artistName, Albums.title)
.join(Albums)
.on(Artists.artistId, Albums.artistId, JoinOp.LT)
.orderBy(Artists.artistName)
.limit(15, 10)
.execute(con)Content copied to clipboard
Return
A SelectStatement that can be further modified (e.g., with WHERE, ORDER BY) or executed.
Author
MOHAMMAD AZIM ANSARI
Parameters
left
The column from the left table in the comparison.
right
The column from the right table in the comparison.
join Op
The operator to use for the comparison (e.g., EQ, NEQ, GT). Defaults to JoinOp.EQ (=).
and
A lambda function to build an additional AND clause.
or
A lambda function to build an additional OR clause.
Type Parameters
C
The data type of the columns being compared.