Home › Learn › SQL › Shaping results

LIKE

Lesson 7 of 26. Match text patterns.

LIKE compares text against a pattern where % stands for any run of characters (including none) and _ for exactly one. name LIKE 'D%' matches names starting with D; '%set' names ending with "set"; '%cable%' names containing "cable". In SQLite, LIKE ignores case for ASCII letters.

For anything more elaborate, databases offer regular expressions or full-text search, but LIKE covers most everyday "contains" and "starts with" questions.

SELECT name FROM customers WHERE name LIKE '%son';

Your task

Show the name of every product whose name starts with D or ends with set.

Hint 1

name LIKE 'D%' OR name LIKE '%set'

Show the solution
SELECT name FROM products WHERE name LIKE 'D%' OR name LIKE '%set';

    Runs SQLite compiled to WebAssembly in this tab; the database is rebuilt before every run.