In a string, if a sequence has a special meaning, each sequence starts with a backslash ("") and is called an escape character. MySQL recognizes the following escape characters:
0
An ASCII 0 (NUL) character.
'
It is a string of 39 ASCII single quotes.
"
An ASCII 34 double quotation mark ("") character.
An ASCII 8 return character.
An ASCII 10 line break.
R
An ASCII 13 carriage return.
T
An ASCII 9 TAB ).
Z
ASCII (26) (Control-Z ). In Windows, ASCII (26) represents the end of a file. (ASCII (26) may cause problems when mysql database <filename is used .)
An ASCII 92 backslash ("") character.
%
An ASCII 37 "%" character. It is used to search for the text instance of "%" in the body. Otherwise, "%" is interpreted as a wildcard.
_
An ASCII 95 '_' character. It is used to search for the text instance of "_" in the body. Otherwise, "_" is interpreted as a wildcard.
Note that if "%" or "_" is used in some body environments, strings "%" and "_" are returned instead of "%" and "_".
Strings that contain quotation marks can be written in the following ways:
A string is referenced by a single quotation mark ('). The single quotation mark (') character in the string can be escaped by a single quotation mark.
A string is referenced by double quotation marks (""). The character "" In this string can be escaped.
You can also add an escape character "" Before the quotation marks to escape.
A string is referenced by double quotation marks (""). The single quotation marks (') in the string do not need to be treated specially and do not need to be repeated or escaped. Similarly, if a string is referenced by single quotation marks ('), the double quotation marks ("") in the string do not need to be treated specially and do not need to be repeated or escaped.
The following SELECT statement demonstrates how quotes and escaping work:
Mysql> SELECT 'hello', '"hello"', '"hello" "', 'Hello', 'Hello'