Skip to main content

Inner Join

Definition

The innerJoin method allows you to add the INNER JOIN clause to the query.

Available methods

1. innerJoin(KJoinDefinition kJoinDefinition)

  • kJoinDefinition: which contains all necessary information to the INNER JOIN clause.

2. innerJoin(KRaw kRaw)

  • kRaw: is a raw content which will be added in the INNER JOIN clause.

Method hierarchy

The innerJoin method can be used right after the following methods or objects:

and the subsequent methods that can be called are:

Example: KCondition

Java code:

k
.select(APP_USER.EMAIL, ROLE.NAME)
.from(APP_USER)
.innerJoin(
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
INNER 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)
.innerJoin(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
INNER 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)
.innerJoin(APP_USER.joinRole())
.multiple();

SQL generated:

SELECT au.email, ro.name
FROM app_user au
INNER JOIN role ro ON (au.role_id = ro.id)

Parameters:

  • None