Wildcard SQL Tutorial

WildcardDefinition
%Represents zero or more characters
_Represents exactly one character
[char list]Represents any single character in charlist
[^char list]
or
[!char list]
Represents any single character not in charlist

Students table:

IDNAMESTATE
1TomArizona
2MartinTexas
3HelenFlorida
4TaniaCalifornia
5HarryColorado

_ Wildcard Example:

Select the student with a name that starts with any character, followed by "ar".
SELECT * FROM students WHERE name LIKE '_ar';

_ Wildcard Result:

IDNAMESTATE
2MartinTexas
5HarryColorado

[char list] Wildcard Example:

Select the student with a name that starts with any character from char list.
SELECT * FROM students WHERE name LIKE '[tma]%';

[char list] Wildcard Result:

1TomArizona
2MartinTexas
4TaniaCalifornia

[!char list] Wildcard Example:

Select the student with a name that do not starts with any character from char list.
SELECT * FROM students WHERE name LIKE '[!tma]%';

[!char list] Wildcard Result:

3HelenFlorida
5HarryColorado