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: A keyword that inverts the return value.
pattern: The pattern that is compared to the expression.
Examples
SELECT 'pancake' LIKE '%cake'
-- True
SELECT 'pancake' NOT LIKE '%cake'
-- False
expression [ NOT ] LIKE pattern ESCAPE escape_character → boolean
expression: The expression to compare.
NOT: A keyword that inverts the return value.
pattern: The pattern that is compared to the expression.
escape_character: Putting escape_character before a wildcard in pattern makes LIKE treat the wildcard as a regular character when it appears in expression.
Examples
SELECT '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: A keyword that inverts the return value.
ANY or SOME or ALL: Keywords indicating whether the expression must match at least one pattern or must match all patterns.
pattern: One or more
STRING
expressions.
Examples
SELECT '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
Last updated
Was this helpful?