Wildcards
The “=” operator is used to find exact matches for text fields, including capitalisation:
WHERE surname = 'Johnson'
|
The LIKE operator can also be used to find exact matchs, but capitalisation is ignored:
WHERE surname LIKE 'johnson'
|
The main purpose of the LIKE operator is to allow use of wildcards, where only parts of the string pattern are specified.
SQL |
MS Access |
|
&
|
*
|
matches zero, one or many characters |
_
|
?
|
matches a single character |
Examples:
WHERE surname LIKE 'Thom%'
|
WHERE surname LIKE '%son'
|
WHERE surname LIKE 'Thom%son'
|
WHERE surname LIKE '%is%'
|
WHERE surname LIKE 'm_%_%'
|