Skip to main content

Intersect All

Definition

The intersectAll method allows you to add the INSERSECT ALL operator to the query.

Available methods

1. intersectAll(KQueryAllowedToCombining kQueryAllowedToCombining)

  • kQueryAllowedToCombining: is a subquery which will be supplied to the INSERSECT ALL operator.

Method hierarchy

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

and the subsequent methods that can be called are:

Example

Java code:

final KWhere kQuery1 =
k
.select(
APP_USER.LAST_NAME,
APP_USER.FIRST_NAME,
toChar(APP_USER.CREATED_AT, "MM")
)
.from(APP_USER)
.where(toChar(APP_USER.CREATED_AT, "MM").eq("10"))
.and(cast(toChar(APP_USER.CREATED_AT, "YYYY"), integer()).lt(2022));

k
.select(
APP_USER.LAST_NAME,
APP_USER.FIRST_NAME,
toChar(APP_USER.CREATED_AT, "YYYY")
)
.from(APP_USER)
.where(toChar(APP_USER.CREATED_AT, "YYYY").eq("2022"))
.intersectAll(kQuery1)
.multiple();

SQL generated:

SELECT
au.last_name,
au.first_name,
TO_CHAR(au.created_at, ?1)
FROM app_user au
WHERE TO_CHAR(au.created_at, ?2) = ?3
INSERSECT ALL (
SELECT
au.last_name,
au.first_name,
TO_CHAR(au.created_at, ?4)
FROM app_user au
WHERE TO_CHAR(au.created_at, ?5) = ?6
AND CAST(TO_CHAR(au.created_at, ?7) AS INTEGER) < ?8
)

Parameters:

  • ?1: "YYYY"
  • ?2: "YYYY"
  • ?3: "2022"
  • ?4: "MM"
  • ?5: "MM"
  • ?6: "10"
  • ?7: "YYYY"
  • ?8: 2022