Wildcards are the placeholders that make pattern matching possible. Paired with the LIKE operator, they let you search for text by shape instead of exact value — names starting with a letter, codes ending in a suffix, anything containing a word. SQL has two you’ll use constantly, % and _, plus a bracket form in some databases.
Run the examples live below — a real SQL engine in your browser — and watch each wildcard change what matches.
Try it — move the wildcard
Sample tables you can query
The two wildcards you’ll use everywhere
| Wildcard | Matches | Read it as |
|---|---|---|
% | any run of characters, including none | ”anything can go here” |
_ | exactly one character | ”one character goes here” |
Where you place them defines the pattern:
'W%'— starts with W (Wthen anything).'%e'— ends with e (anything thene).'%o%'— contains an o (anything,o, anything).'W%e'— starts with W and ends with e.
% — any run of characters
The percent sign is the workhorse. It matches zero, one, or many characters, so it’s how you say “starts with,” “ends with,” or “contains”:
SELECT name
FROM products
WHERE name LIKE '%Scarf%';Because % also matches nothing, 'Scarf%' matches both “Scarf” and “Scarf Wool” — the trailing % is happy to match an empty string.
_ — exactly one character
The underscore matches a single character — no more, no less. Use it when position matters:
SELECT name
FROM customers
WHERE name LIKE '_i%';That pattern means: any first character, then i, then anything — i.e. names whose second letter is i. Swap in more underscores to pin down more positions: '____' matches any exactly-four-character value.
% (any run) vs _ (exactly one)
Sample tables you can query
Combining wildcards
Mix % and _ and add literal characters to describe precise shapes:
SELECT name
FROM products
WHERE name LIKE 'W%e';Start with W, allow anything in the middle, end with e. You can stack them — '_a%t' means “second letter a, ending in t” — as specific as you need.
Anchors + wildcards
Sample tables you can query
The bracket wildcard [ ] (SQL Server)
SQL Server (and MS Access) add a third form: square brackets match any one character from a set or range.
-- SQL Server only
WHERE name LIKE '[ACW]%' -- starts with A, C, or W
WHERE code LIKE '[0-9]%' -- starts with a digit
WHERE name LIKE '[^A]%' -- does NOT start with AThis is not standard SQL — PostgreSQL, MySQL, and SQLite don’t support [ ] in LIKE (you’d use a regular expression like ~ or REGEXP instead). This playground follows the portable % / _ behavior, so the bracket form is shown here for reference only.
Escaping a literal % or _
To search for an actual percent sign or underscore, escape it with your database’s ESCAPE clause so it’s treated as a literal:
WHERE discount_code LIKE '50\% off' ESCAPE '\'Practice
Return every customer whose name has "i" as its second character. Select name.
Sample tables you can query
Return every product whose name starts with "W" and ends with "e". Select name.
Sample tables you can query
Frequently asked questions
What are the wildcards in SQL? % matches any run of characters (including none), and _ matches exactly one character. SQL Server also supports [ ] for a character set or range. They’re used with LIKE.
What’s the difference between % and _? % matches any number of characters; _ matches exactly one. 'A_' matches a two-character value starting with A; 'A%' matches any value starting with A.
Do wildcards work in MySQL and PostgreSQL? % and _ work everywhere. The bracket form [ ] is SQL Server / Access only; elsewhere use a regular expression (REGEXP in MySQL, ~ in PostgreSQL).
How do I match a literal % sign? Escape it with the ESCAPE clause: LIKE '50\% off' ESCAPE '\'.
From patterns to pipelines
Wildcard matching is one way to filter text. When that filtering runs continuously across data sources, ET1 makes it a visual Filter node with a live preview of matching rows.
Keep going: see the LIKE operator that wildcards plug into, match a list of exact values with IN, or combine conditions with AND, OR, and NOT.