LIKE matches too much: _ and % are wildcards (escape them)
Searching for text containing _ or % returns unexpected rows because LIKE treats them as wildcards.
LIKE underscore matches any characterLIKE with percent sign matches too many rowsescape underscore in LIKELIKE ESCAPE clauseLIKE wildcard injection Meaning
In LIKE, % matches any string and _ matches any single character. Escape literal characters with an ESCAPE clause (LIKE '50\%%' ESCAPE '\'), and always escape user input to avoid unintended matches (and injection-style surprises).
Common causes
- Searching for file names with underscores
- User input containing % or _
- No ESCAPE character defined
- Leading wildcard preventing index use
- Case-sensitivity differences between databases
⚡ Quick fix
- Escape wildcards:
LIKE 'a\_b%' ESCAPE '\' - Escape user-provided search terms
- Use full-text search for large text
Detailed fix by platform
SQL
SELECT * FROM files WHERE name LIKE 'report\_2026%' ESCAPE '\';
How to diagnose
- Input — Has _ or %?
- ESCAPE — Used?
- Index — Usable?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in SQL
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026