Right Join
Definition
The rightJoin method allows you to add the RIGHT JOIN clause to the query.
Available methods
1. rightJoin(KJoinDefinition kJoinDefinition)
- kJoinDefinition: which contains all necessary information to the
RIGHT JOINclause.
2. rightJoin(KRaw kRaw)
- kRaw: is a raw content which will be added in the
RIGHT JOINclause.
Method hierarchy
The rightJoin method can be used right after the following methods or objects:
and the subsequent methods that can be called are:
from,innerJoin,leftJoin,rightJoin,fullJoin,crossJoin,where,groupBy,window,except,exceptAll,intersect,intersectAll,union,unionAll,orderBy,limit,offset,fetch,single,multiple
Example: KCondition
Java code:
k
.select(APP_USER.EMAIL, ROLE.NAME)
.from(APP_USER)
.rightJoin(
ROLE.on(
APP_USER.ROLE_ID.eq(ROLE.ID).and(ROLE.TENANT_ID.isNull())
)
)
.multiple();
SQL generated:
SELECT au.email, ro.name
FROM app_user au
RIGHT JOIN role ro ON (
au.role_id = ro.id AND ro.tenant_id IS NULL
)
Parameters:
- None
Example: KRaw
Java code:
k
.select(APP_USER.EMAIL, raw("ro.name"))
.from(APP_USER)
.rightJoin(raw("role ro ON (au.role_id = ro.id AND ro.id < 10)"))
.multiple();
SQL generated:
SELECT au.email, ro.name
FROM app_user au
RIGHT JOIN role ro ON (
au.role_id = ro.id AND ro.id < 10
)
Parameters:
- None
Example: Predefined method
Java code:
k
.select(APP_USER.EMAIL, ROLE.NAME)
.from(APP_USER)
.rightJoin(APP_USER.joinRole())
.multiple();
SQL generated:
SELECT au.email, ro.name
FROM app_user au
RIGHT JOIN role ro ON (au.role_id = ro.id)
Parameters:
- None