Skip to main content

Right

Definition

The right method allows you to add the RIGHT function to the query. The RIGHT function return last n characters in the string. When n is negative, return all but first |n| characters.

Available methods

  • right(KColumn kColumn, int n): Receives a KColumn or KTableColumn and an int which will be supplied to the RIGHT function.
  • right(KValTextField kValTextField, int n): Receives a KValTextField and an int which will be supplied to the RIGHT function.

To use this way, you need to import the static functions as follows:

import static com.myzlab.k.KFunction.*;

Example: (KColumn, int)

Java code:

k
.select(
right(APP_USER.FIRST_NAME, 2)
)
.from(APP_USER)
.multiple();

SQL generated:

SELECT
RIGHT(au.first_name, 2)
FROM app_user au

Parameters:

  • None

Example: (KValTextField, int)

Java code:

k
.select(
right(val("A text"), 2)
)
.single();

SQL generated:

SELECT RIGHT(?1, 2)

Parameters:

  • ?1: "A text"