Basics · Lesson 9 of 19

Pattern Matching with LIKE

LIKE searches for patterns in text.

Wildcards:

  • % matches any number of characters
  • _ matches exactly one character

Examples:

WHERE first_name LIKE 'J%'     -- Starts with J
WHERE email LIKE '%@gmail.com' -- Ends with @gmail.com
WHERE first_name LIKE '_ohn'   -- 4 letters, ends in 'ohn'

NOT LIKE finds non-matching patterns.

Check your understanding

Find all employees whose first name starts with 'J'.

Practice it on a real question

All SELECT & filtering questions

Practice on your iPhone

Query Dojo for iPhone has 85 interview questions, timed mock interviews and a tile builder, so you can write queries without a keyboard.

Get the app