Wildcard | Definition |
---|---|
% | 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:
ID | NAME | STATE |
---|---|---|
1 | Tom | Arizona |
2 | Martin | Texas |
3 | Helen | Florida |
4 | Tania | California |
5 | Harry | Colorado |
_ 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:
ID | NAME | STATE |
---|---|---|
2 | Martin | Texas |
5 | Harry | Colorado |
[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:
1 | Tom | Arizona |
2 | Martin | Texas |
4 | Tania | California |
[!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:
3 | Helen | Florida |
5 | Harry | Colorado |