LIKE
Pattern-matching conditions
Description
The LIKE operator compares a string expression, such as a column name, with a pattern that uses the wildcard characters % (percent) and _ (underscore). LIKE pattern matching always covers the entire string. To match a sequence anywhere within a string, the pattern must start and end with a percent sign. (Redshift SQL Language reference LIKE).
This grammar is fully supported in Snowflake.
Grammar Syntax
expression [ NOT ] LIKE | ILIKE pattern [ ESCAPE 'escape_char' ]Sample Source Patterns
Setup data
CREATE TABLE like_ex(name VARCHAR(20));
INSERT INTO like_ex VALUES
('John Dddoe'),
('Joe Doe'),
('Joe Doe '),
(' Joe Doe '),
(' Joe \n Doe '),
('John_down'),
('Joe down'),
('Elaine'),
(''),
(null),
('1000 times'),
('100%');Like
Input Code:
Joe Doe
Joe Doe
Joe Doe
Joe Doe
John Dddoe
Output Code:
Joe Doe
Joe Doe
Joe Doe
Joe Doe
John Dddoe
Not like
Input Code:
100%
1000 times
Elaine
Joe down
John_down
dd
Output Code:
100%
1000 times
Elaine
Joe down
John_down
Escape characters
Input Code:
John_down
100%
Output Code:
John_down
100%
ILike
Input Code:
FALSE
TRUE
Output Code:
FALSE
TRUE
Operators
The following operators are translated as follows:
~~
LIKE
!~~
NOT LIKE
~~*
ILIKE
!~~*
NOT ILIKE
Input Code:
TRUE
FALSE
TRUE
FALSE
Output Code:
TRUE
FALSE
TRUE
FALSE
Known Issues
The behavior of fixed char types may differ. Click here for more information.
Related EWIs
There are no known issues.
Last updated
