SQL Wildcards

A wildcard character can be used to substitute for any other character(s) in a string.

SQL Wildcard Characters

In SQL, wildcard characters are used with the SQL LIKE operator.

SQL wildcards are used to search for data within a table.

With SQL, the wildcards are:

Wildcard Description
% A substitute for zero or more characters
_ A substitute for a single character
[charlist] Sets and ranges of characters to match
[^charlist] or
[!charlist]
Matches only a character NOT specified within the brackets

 

Example

SELECT * FROM Customers
 WHERE City LIKE '[bsp]%';

or

SELECT * FROM Customers
WHERE City LIKE 'L_n_on';

or

SELECT * FROM Customers
WHERE City LIKE '_erlin';

or

SELECT * FROM Customers
WHERE City LIKE '%es%';