Try OpenEdge Now
skip to main content
SQL Reference
SQL Reference : OpenEdge SQL Language Elements : Data types : Relational operators : Quantified Predicate : LIKE Predicate
LIKE Predicate
The LIKE predicate searches for strings that have a certain pattern. The pattern is specified after the LIKE keyword in a string constant. The pattern can be specified by a string in which the underscore ( _ ) and percent sign ( % ) characters have special semantics.
Use the ESCAPE clause to disable the special semantics given to the characters ( _ ) and
( % ). The escape character specified must precede the special characters in order to disable their special semantics.


This is the syntax for a LIKE predicate:
column_name [ NOT ] LIKE string_constant[ ESCAPE escape_character]


*The column_name specified in the LIKE predicate can be a column, a string constant, or an arbitrary character expression (such as SUBSTRING or LTRIM).
*The string_constant may be a string constant or a scalar function call.
*The escape_character must be a one character string constant.
*A percent sign ( % ) in the pattern matches zero or more characters of the column string.
*An underscore symbol ( _ ) in the pattern matches any single character of the column string.
*The LIKE predicate is multi‑byte enabled. The string_constant and the escape_character may contain multi‑byte characters, and the escape_character can be a multi‑byte character. A percent sign ( % ) or an underscore ( _ ) in the string_constant can represent a multi‑byte character. However, the percent sign or underscore itself must be the single‑byte ASCII encoding.


This example illustrates three ways to use the LIKE predicate:
cust_name LIKE '%Computer%'
cust_name LIKE '___'
item_name LIKE '%\_%' ESCAPE '\'
In the first LIKE clause, for all strings with the substring 'Computer' the predicate evaluates to true. In the second LIKE clause, for all strings which are exactly three characters long the predicate evaluates to true. In the third LIKE clause the backslash character ( \ ) is specified as the escape character, which means that the special interpretation given to the underscore character ( _ ) is disabled. The pattern evaluates to TRUE if the item_name column has embedded underscore characters.