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
SQL CAST vs CONVERT: Safe Type Changes Across Databases
By Sharon Ben-Moshe · Aug 21, 2026
CAST turns one SQL data type into another. Learn when CONVERT differs, how invalid values fail, and how to write portable conversions.
Read postSQL String Concatenation Across Databases
By Sharon Ben-Moshe · Aug 21, 2026
Concatenate SQL strings with || or CONCAT, but NULL behavior differs by database. See portable patterns for PostgreSQL, MySQL, SQL Server, and BigQuery.
Read postTry it now
Paste your SQL into sqlfmt — format, validate, and catch typos free in your browser.