LIKE & Pattern Matching in SQL
From the SQL cheat sheet ยท SELECT & Filtering ยท verified Jul 2026
LIKE & Pattern Matching
Filter text with wildcard patterns.
sql
-- % matches any number of characters
SELECT * FROM users WHERE name LIKE 'J%'; -- Starts with J
SELECT * FROM users WHERE email LIKE '%@gmail%'; -- Contains @gmail
-- _ matches exactly one character
SELECT * FROM users WHERE name LIKE '_ohn'; -- ?ohn
-- NOT LIKE
SELECT * FROM users WHERE name NOT LIKE '%test%';๐ก % matches any number of characters (including zero); _ matches exactly one
โก PostgreSQL uses ILIKE for case-insensitive matching; MySQL LIKE is case-insensitive by default
๐ LIKE '%term%' cannot use indexes efficiently โ consider full-text search for large tables
๐ข Use ESCAPE to match literal % or _ characters in your pattern
likewildcardspattern-matching