LearnSQLSQL LIKE
FILTERING

SQL LIKE

Find text patterns with % and _ wildcards.

After this lessonSearch prefixes, suffixes and text fragments.

How it works

LIKE is useful when an exact equality check is too strict. The % wildcard represents any number of characters, while _ represents exactly one character.

Pattern matching is convenient for codes, descriptions and naming conventions, but a leading % can be expensive on very large indexed tables.

REAL WORK

Find all submix identifiers containing 'AK' or all materials whose description starts with 'Filter'.

SYNTAX

The pattern

SELECT columns
FROM table
WHERE column LIKE 'pattern';

Example

SELECT ProductID, ProductName
FROM Products
WHERE ProductName LIKE '%Cable%';
TRY IT

Run the example

Edit the query and run it against the built-in demo tables. Nothing is sent to a server.

SQL playground

The learning runner supports SELECT, WHERE, LIKE, IN, BETWEEN, GROUP BY, HAVING, JOIN, aggregates, ORDER BY and LIMIT. Advanced lessons explain additional production SQL concepts even when the mini runner does not execute that syntax.

QUICK CHECK

Which pattern finds values that start with 'PO-'?

Progress is stored only in this browser. No account required.