w3resource
SQL Tutorial

SQL [charlist] wildcards

[charlist] wildcards

The [charlist] WILDCARDS are used to represent any single character within a charlist.

The [^charlist] and [!charlist] WILDCARDS is used to represents any single character not in the charlist.

Example:

Sample table: agents


To get all rows from the table 'agents' with following condition -

1. the 'agent_name' must begin with the letter 'a' or 'b' or 'i'

the following sql statement can be used :

SELECT *
FROM agents
WHERE agent_name  LIKE '[abi]%';

Sql [^charlist] wildcards

Sample table: agents


To get all rows from the table 'agents' with following condition -

1.the 'agent_name' must not begin with the letter 'a' or 'b' or 'i',

the following sql statement can be used :

SELECT *
FROM agents
WHERE agent_name  LIKE '[^abi]%';

Sql [!charlist] wildcards

Sample table: agents


To get all rows from the table 'agents' with following condition -

1.the 'agent_name' must not begin with the letter 'a' or 'b' or 'i',

the following sql statement can be used :

SELECT *
FROM agents 
WHERE agent_name  LIKE '[!abi]%';

See our Model Database

Practice SQL Exercises

Want to improve the above article? Contribute your Notes/Comments/Examples through Disqus.

Previous: Underscore(_)
Next: Functions