How to search with LIKE

Match a pattern

LIKE compares text to a pattern rather than requiring an exact match.

SELECT title
FROM courses
WHERE title LIKE 'Learn%';

Use two wildcards

  • % matches zero or more characters
  • _ matches exactly one character
  • Ordinary characters match themselves

Understand case behavior

SQLite LIKE is case-insensitive for ASCII by default. PostgreSQL LIKE is case-sensitive and offers ILIKE; MySQL behavior depends on the column collation.

Escape carefully

To search for literal wildcard characters, specify an escape character. Support is broad, but exact escaping defaults differ among databases.

WHERE code LIKE 'SAVE!_%' ESCAPE '!'