typestar

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

  1. % matches any run of characters, _ matches exactly one.
  2. Leading wildcards cannot use an index, so they scan the table.
  3. LOWER on both sides makes the match case insensitive.

Keywords and builtins used here

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.

Type this snippet

Step 3 of 5 in Filtering, step 11 of 23 in Language basics.

← Previous Next →