Home / SQL / Reference / Filtering

SQL LIKE

Match text against a pattern.

Syntax

WHERE col LIKE 'pattern'

% matches any number of characters (including none) and _ exactly one.

Example

Query (on the shop database used in the SQL course)

SELECT name
FROM products
WHERE name LIKE '%desk%';

Result

name
Standing desk
Desk lamp

2 rows

Good to know. LIKE ignores case for English letters in SQLite but not in PostgreSQL (use ILIKE there).

Related

Learn it step by step in the free lesson WHERE: Filtering Rows, with exercises that check your queries.