Categories: String
LIKE
Tests whether an expression matches one or more patterns. Comparisons are case-sensitive.
Syntax
expression [ NOT ] LIKE pattern → boolean
- expression: The expression to compare.
- NOT (optional): A keyword that inverts the return value.
- pattern: The pattern that is compared to the expression.
Examples
LIKE exampleSELECT 'pancake' LIKE '%cake'
-- True
SELECT 'pancake' NOT LIKE '%cake'
-- False
expression [ NOT ] LIKE pattern ESCAPE escape_character → boolean
- expression: The expression to compare.
- NOT (optional): A keyword that inverts the return value.
- pattern: The pattern that is compared to the expression.
- escape_character (optional): Putting escape_character before a wildcard in pattern makes LIKE treat the wildcard as a regular character when it appears in expression.
Examples
LIKE exampleSELECT '50%_Off' LIKE '%50!%%' ESCAPE '!'
-- True
SELECT '%SalesData%/Users/Jane' NOT LIKE '/%SalesData/%//Users/%' ESCAPE '/'
-- False
expression [ NOT ] LIKE { ANY | SOME | ALL } ( [ pattern [, ...] ] ) → boolean
- expression: A
STRING
expression. - NOT (optional): A keyword that inverts the return value.
- ANY or SOME or ALL (optional): Keywords indicating whether the expression must match at least one pattern or must match all patterns.
- pattern: One or more
STRING
expressions.
Examples
LIKE exampleSELECT 'Spark' LIKE ALL ('_park', '%ark')
-- True
SELECT 'Spark' NOT LIKE ALL ('_park', '%ark')
-- False
SELECT 'Spark' LIKE SOME ('meow', 'woof')
-- False
SELECT 'Spark' NOT LIKE SOME ('meow', 'woof')
-- True
SELECT 'Spark' LIKE ANY ('_park', '_mart')
-- True
SELECT 'Spark' NOT LIKE ANY ('_park', '_mart')
-- False