LQ
SQL Reference
Practice →
SQL ReferenceFunctionsLIKE & Pattern Matching

LIKE & Pattern Matching

Filter rows where text matches a pattern.

Questions this answers
  • How do I find names that start with a certain letter?
  • How do I search for text containing a word?
  • How do I match emails from a specific domain?

How it works

LIKE lets you filter text by pattern. % matches any sequence of characters (including none). _ matches exactly one character. It's case-insensitive in most databases.

Starts with

SELECT name FROM artists WHERE name LIKE 'T%';

Contains

SELECT name FROM artists WHERE name LIKE '%Swift%';

Exact length with _

-- Names exactly 4 characters long
SELECT name FROM artists WHERE name LIKE '____';

NOT LIKE

SELECT name FROM artists WHERE name NOT LIKE '%feat%';

Ready to practise LIKE & Pattern Matching?

Solve real exercises with AI feedback — free to start.

Try it free →