Search for wildcard characters
You can search for wildcard characters. There are two ways to specify characters that are typically used as wildcards:
- Use the escape keyword to define the escape character. In mode, when an escape character is placed before a wildcard, the wildcard is interpreted as a common character. For example, to search for strings containing string 5% at any position, use:
WHERE ColumnA LIKE '%5/%%' ESCAPE '/'
In the like clause above, the leading and ending percent signs (%) are interpreted as wildcards, while the percent signs after the slash (/) are interpreted as characters %.
- Square brackets ([]) contain only the wildcard character. To search for a break number (-) instead of specifying the search range, specify the break number as the first character in square brackets:
WHERE ColumnA LIKE '9[-]5'
The following table shows the usage of wildcards enclosed in square brackets.
Symbol |
Description |
Like '5 [%]' |
5% |
Like '5%' |
5 followed by a string of 0 or more characters |
Like '[_] N' |
_ N |
Like '_ N' |
An, in, on (and so on) |
Like '[A-CdF]' |
A, B, C, D, or F |
Like '[-ACDF]' |
-, A, C, D, or F |
Like '[[]' |
[ |
Like ']' |
] |
If you use like to compare strings, all the characters in the pattern string, including the start space and/or trailing space, are meaningful. If the query comparison requires that all rows containing "ABC" (there is a space after ABC) be returned, the column value "ABC" (no space after ABC) is not returned. However, this is not the case. Ignore spaces at the end of the expression to be matched by the pattern. If the query comparison requires that all rows containing "ABC" (without spaces after ABC) be returned, all rows starting with "ABC" with zero or multiple trailing spaces are returned.