Compares a character value to a specified character pattern.

Syntax

[ NOT ] LIKE 'charPattern' [ ESCAPE 'escapeChar' ]

Arguments

  • charPattern: a character expression of one of these types, or an expression that resolves to one of these types: CHAR, VARCHAR, or LONG VARCHAR. charPattern can include these wildcards:

  • _: An underscore represents exactly one character in position in the pattern. For example, the pattern ‘12_45’ would match ’12 45’, ‘12345’, or ‘12A45’.

  • %: A percent symbol represents none or more characters in position in the patterns. For example, the pattern ‘12%’ would match ‘12’, ‘1234567’, or ’12 Apples’.

  • escapeChar: a character to use as an escape character within charPattern. escapeChar cannot be the last character in charPattern.

Returns

  • The row or value, when the pattern match is true.

Additional Information

  • LIKE comparisons are not case sensitive.

Examples

SELECT firstName, lastName FROM MYSQL.inventory.cust WHERE lastName LIKE 'Smi%';

SELECT companyName FROM MYSQL.inventory.cust WHERE companyName LIKE 'Over=% Discounts' ESCAPE '=';

VALUES 'John Smith' LIKE '%Smith'
-- Returns true