LIKE is a comparison operator that evaluates whether a column value matches a specified pattern. It is case-sensitive or case-insensitive depending on the database collation and dialect. Two wildcards are available: % represents any sequence of zero or more characters, while _ represents exactly one character. You can combine literal characters and wildcards to build flexible search conditions.By default, the backslash (\\) is treated as an escape character in some systems, but the SQL standard lets you explicitly define any single-character escape sequence with the ESCAPE clause. When ESCAPE is present, the chosen character forces the following character to be interpreted literally, allowing you to search for the wildcard symbols themselves.LIKE returns TRUE, FALSE, or UNKNOWN (NULL) in three-valued logic. NOT LIKE negates the result. Unlike regular expressions, LIKE patterns are simple and portable, making them useful for quick substring or prefix searches, though they may not use indexes efficiently when the pattern starts with a leading wildcard.
pattern
(string) - Quoted string containing % and/or _ wildcards.escape
(string, optional) - Single character following the ESCAPE keyword that defines the escape character for the pattern.ILIKE, REGEXP, SIMILAR TO, NOT LIKE, ESCAPE, COLLATION, BETWEEN, IN
SQL-92
It matches exactly one character. For example, 'A_' matches 'AB' and 'A1' but not 'ABC'.
NOT LIKE returns TRUE when the value does not match the pattern, effectively negating the condition.
Yes. You can use AND, OR, and parentheses to chain multiple LIKE conditions or mix them with other predicates.
Choose REGEXP when you need complex pattern matching such as character classes or quantifiers that LIKE cannot express.