Pattern matching with LIKE in SQL
LIKE compares text against a pattern of wildcards.
SELECT
id,
email
FROM users
WHERE email LIKE '%@example.com'
AND LOWER(name) LIKE 'a%'
AND phone LIKE '555-____';
How it works
%matches any run of characters,_matches exactly one.- Leading wildcards cannot use an index, so they scan the table.
LOWERon both sides makes the match case insensitive.
Keywords and builtins used here
ANDFROMLIKELOWERSELECTWHERE
The run, in numbers
- Lines
- 7
- Characters to type
- 113
- Tokens
- 22
- Three-star pace
- 75 tpm
At the three-star pace of 75 tokens a minute, this run takes about 18 seconds.
Step 3 of 5 in Filtering, step 11 of 23 in Language basics.