Home > Article > Backend Development > The use of wildcards, escape characters and '[' signs in SQL (downmoon)_PHP tutorial
1. Instructions for searching for wildcard characters
You can search for wildcard characters. There are two ways to specify characters that are commonly used as wildcards:
Use the ESCAPE keyword to define escape characters. When an escape character precedes a wildcard character in a pattern, the wildcard character is interpreted as an ordinary character. For example, to search for a string that contains 5% of the string anywhere, use:
WHERE ColumnA LIKE '%5/%%' ESCAPE '/'
In the above LIKE clause, the leading and trailing 100 A semicolon (%) is interpreted as a wildcard character, and a percent sign after a slash (/) is interpreted as the % character.
Enclose only the wildcard character itself within square brackets ([ ]). To search for a dash (-) instead of specifying a search range with it, specify the dash as the first character inside square brackets:
WHERE ColumnA LIKE '9[-]5'
The following table shows the values enclosed in Usage of wildcard characters within square brackets.