602SQL Documentation Index  

LIKE Predicate

LIKE_predicate ::= expression [ NOT ] LIKE expression2 [ ESCAPE expression3 ]

The LIKE predicate allows the comparison of the expression with a model specified by the expression2. All expressions must be of the character string type.

The contents of the expression are compared with the expression2 characterwise with these exceptions: the underscore character "_" in expression2 corresponds with any single character in expression and the percent character "%" in expression2 corresponds with any character string (even empty) in expression.

If expression3 is specified, the value must be only a single character, otherwise a sqlstate 22019 occurs. If this character is used in expression2 immediately before the _ or % character, then this represents the _ or % character (the expression must contain the same character).

If there exists a to match all characters in expression and expression2 according to these rules, the predicate equals TRUE, FALSE otherwise.

Since version 9.5, regular expressions are supported in 602SQL (see the REGEXP_LIKE function).

Usage example:

Select names ending with "%ova" from New York

SELECT Employees.name
FROM Employees
WHERE (name LIKE '%ova') AND (city LIKE 'New York%')

Find a code that has the % character on the second place:

WHERE code LIKE '_\%%' ESCAPE '\'