The SQL wildcards “%” and “_” are well documented and widely known. However as w3schools explains, there are also “charlist” style wildcards for matching a single character within or outside a given range, for example to find all the people called Carl but not those called Earl:
select * from Person where FirstName like '[A-D]arl'
… or to find the opposite, use either:
select * from Person where FirstName like '[!A-D]arl'
or (depending on the RDBMS, presumably):
select * from Person where FirstName like '[^A-D]arl'
Is this type of wildcard part of the SQL-92 standard, and what databases actually support it? For example:
- Oracle 11g doesn’t support it
- SQL Server 2005 supports it, with the negation operator being “^” (not “!”)
The SQL-99 Standard has a
SIMILAR TOpredicate which uses “charlist” style as well as the “%” and “_” wildcard characters.Nothing similar (no pun intended) in the SQL-92 Standard, though.