LIKE

Creates a LIKE pattern-matching expression.

This infix function checks if the column's value matches a given string pattern. The pattern can include wildcards:

  • % percent: Matches any sequence of zero or more characters.

  • _ underscore: Matches any single character.

To match literal % or _, you must use an ESCAPE clause. This overload does not provide an escape character. For that, use the overload that accepts an escape parameter.

Example

// Find all employees whose first name starts with "J"
// Generates: "first_name" LIKE 'J%'
Employees.firstName LIKE "J%"

// Find employees whose last name is four letters long and ends with "s"
// Generates: "last_name" LIKE '___s'
Employees.lastName LIKE "___s"

Return

An Expression representing the LIKE condition.

Author

MOHAMMAD AZIM ANSARI

Parameters

value

The pattern string to match against.

See also


infix fun <T : String?> KQLiteColumn<*>.LIKE(value: KQLiteColumn<out T>): Clause.Expression


abstract fun KQLiteColumn<*>.LIKE(value: String, escape: Char? = null): Clause.Expression

Creates a LIKE pattern-matching expression with an optional ESCAPE character.

This function checks if the column's value matches a given string pattern. The pattern can include wildcards:

  • % percent: Matches any sequence of zero or more characters.

  • _ underscore: Matches any single character.

This overload allows specifying an escape character, which is used to treat a wildcard character (% or _) as a literal character in the pattern.

Example

// Find items with a name containing a literal '%' symbol
// Generates: "item_name" LIKE 'promo\_%' ESCAPE '\'
Items.itemName.LIKE("promo_%", escape = '\\')

Return

An Expression representing the LIKE condition with an ESCAPE clause.

Author

MOHAMMAD AZIM ANSARI

Parameters

value

The pattern string to match against.

escape

The character to use for escaping wildcards. If null, no ESCAPE clause is generated.

See also