SQL LIKE Wildcards: %, _, and ESCAPE Explained
By Sharon Ben-Moshe · August 21, 2026 · 2 min read
Sharon Ben-Moshe is the founder of sqlfmt, a browser-based SQL formatter and validator with misspelled-keyword suggestions across PostgreSQL, MySQL, SQLite, SQL Server, and BigQuery.
Use SQL LIKE for text patterns without accidental matches. Learn %, _, literal wildcard escaping, case sensitivity, and portable examples.
Quick answer
SQL LIKE compares text to a pattern: `%` matches zero or more characters and `_` matches one character. When the text you need includes either symbol literally, declare an ESCAPE character and prefix that symbol. Case sensitivity and extra wildcard syntax vary by database.
FAQs
What does % mean in SQL LIKE?
In a SQL LIKE pattern, `%` matches a sequence of zero or more characters. `LIKE 'A%'` therefore matches both `A` and longer values that begin with A.
What does _ mean in SQL LIKE?
In a SQL LIKE pattern, `_` matches exactly one character. `LIKE 'A_'` matches two-character values beginning with A, but not A alone.
How do I search for a literal percent sign in SQL?
Choose an escape character and declare it with ESCAPE. For example, `LIKE '%!%%' ESCAPE '!'` treats `!%` as a literal percent sign while the surrounding `%` characters remain wildcards.
Is SQL LIKE case-sensitive?
Case behavior depends on the database and its collation. PostgreSQL has ILIKE for locale-aware case-insensitive matching, while other systems use different features or collations.
Keep reading
The Comprehensive Guide to SQL Data Types: Storage, Precision, and Cross-Dialect Portability
By Sharon Ben-Moshe · Oct 13, 2026
The complete guide to SQL data types across PostgreSQL, MySQL, SQL Server, and SQLite. Numeric precision, character sets, timestamps, and JSON.
Read postThe Definitive Guide to SQL Window Functions: Syntax, Framing, and Real-World Recipes
By Sharon Ben-Moshe · Oct 13, 2026
The comprehensive guide to SQL window functions. Master OVER, PARTITION BY, ORDER BY, window frames (ROWS vs RANGE), and ranking recipes.
Read postTry it now
Paste your SQL into sqlfmt — format, validate, and catch typos free in your browser.