SQL Wildcards (% and _)
Two characters, two very different jobs — any-length match versus exactly-one-character match.
What & Why
% matches any sequence of characters, including zero. _ matches exactly one character, no more, no less.
See How It Works
PATTERNS THAT MATCH `Spring Launch`
| Pattern | Why it matches 'Spring Launch' |
|---|---|
| `Spring%` | Starts with "Spring"; % allows any remaining characters. |
| `%Launch` | Ends with "Launch"; % allows any prefix. |
| `Spring_Launch` | _ matches the single space between the two words. |
| `Spring_______` | Seven underscores match exactly the seven characters in " Launch". |
% matches any number of characters, while _ matches exactly one character.
Now You Try
Practice this concept
Product wants features whose names end with App, using a wildcard pattern rather than exact equality.
Available schema
productPrefix tables with product.table_name.
nameteamreleased_atproduct.features| Column | Type |
|---|---|
| id | integer |
| name | text |
| description | text |
| team | text |
| released_at | timestamp with time zone |
| deprecated_at | timestamp with time zone |
| internal_priority | integer |
query.sql
Sign up free to try it on a real business scenario