In a string, if a sequence has a special meaning, each sequence begins with a backslash (""), called an escape character. MySQL recognizes the following escape characters:
0
An ASCII 0 (NUL) character.
'
An ASCII 39 single quotation mark ("'") character.
"
An ASCII 34 double quote ("") character.
An ASCII 8 backspace.
An ASCII 10 line feed character.
R
An ASCII 13 back-car character.
T
An ASCII 9 tab (tab).
Z
ASCII (control-z). This character can be handled in Windows system ASCII (26) represents the end of a file problem. (ASCII (26) may cause problems when using MySQL database < filename. )
An ASCII 92 backslash ("") character.
%
An ASCII 37 "%" character. It is used to search for text instances of "%" in the body, otherwise this "%" will be interpreted as a wildcard character.
_
An ASCII 95 "_" character. It is used to search for text instances of "_" in the body, otherwise this "_" will be interpreted as a wildcard character.
Note If you use "%" or "_" in some body contexts, you will return the string "%" and "_" instead of "%" and "_".
There are several ways in which a string can contain quotes:
A string is referenced in single quotation marks "'", and the single quote "'" character in the string can be escaped with "".
A string is referenced in double quotation marks "", and the character "" in the string can be escaped by using the "" ".
You can also continue to use the escape character "" in front of the quotes to escape the way.
A string is quoted in double quotes "" "and the single quotation mark in the string" ' "does not require special treatment and does not have to be duplicated or escaped. Similarly, a string is referred to as a single quote "'", and the double quotation mark "" In the string does not require special treatment and does not have to be duplicated or escaped.
The following shows how the SELECT demo quotes and escapes work:
mysql> SELECT ' hello ', ' hello ' ', ' ' Hello ' ', ', ' Hel ' ' lo ', ' Hello