Skip to main content

Or

Definition

The or methods allows you to add the OR operator to a WHERE clause.

Available methods

1. or(KCondition kCondition)

  • kCondition: which contains all the information about the condition that will be added to the WHERE clause with an OR operator.

2. or(KRaw kRaw)

  • kRaw: is a raw content which will be added in the WHERE clause with an OR operator.

Method hierarchy

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

and the subsequent methods that can be called are:

Example: KCondition

Java code:

k
.select(APP_USER.ID, APP_USER.FIRST_NAME)
.from(APP_USER)
.where(APP_USER.CREATED_AT.lt(LocalDateTime.now().minusMonths(1)))
.or(APP_USER.EMAIL.ilk("jHonDoE"))
.multiple();

SQL generated:

SELECT au.id, au.first_name
FROM app_user au
WHERE au.created_at < ?1
OR LOWER(au.email) LIKE ?2

Parameters:

  • ?1: 2022-11-30T13:18:26.390024
  • ?2: "jhondoe"

Example: KRaw

Java code:

k
.select(APP_USER.ID, APP_USER.FIRST_NAME)
.from(APP_USER)
.where(raw("au.role_id IS NOT NULL"))
.or(raw("au.email IS NOT NULL"))
.multiple();

SQL generated:

SELECT au.id, au.first_name
FROM app_user au
WHERE au.role_id IS NOT NULL
OR au.email IS NOT NULL

Parameters:

  • None