Learn SQL Lesson

Pattern Matching with LIKE

The `LIKE` operator matches text patterns using two wildcards:

`%` matches any sequence of characters (including none) `_` matches exactly one character

Examples:

WHERE name LIKE 'A%'       -- names starting with A
WHERE name LIKE '%e'       -- names ending with e
WHERE name LIKE '%li%'     -- names containing "li"
WHERE name LIKE '_o%'      -- names with "o" as the second letter

In DuckDB, `LIKE` is case-sensitive. DuckDB also supports `ILIKE` for case-insensitive matching:

WHERE name ILIKE '%alice%' -- matches Alice, ALICE, alice, etc.

Practice challenge

Find all employees whose name contains the letters li. Return name, ordered by name.

Open interactive editor