For more information, see MySQL escape characters.
For more information, see MySQL escape characters.
MySQL Escape Character "\"
Mfc_basic
MySQL recognizes the following escape characters:
\ 0
An ASCII 0 (NUL) character.
\ N
A newline character.
\ T
A positioning character. Separator
\ R
A carriage return.
\ B
A return character.
\'
A single quotation mark.
\"
A double quotation mark.
A backslash.
\ %
A "%" character. It is used to search for the text instance of "%" in the body. Otherwise, "%" is interpreted as a wildcard.
\_
A "_" character. It is used to search for the text instance of "_" in the body. Otherwise, "_" is interpreted as a wildcard.
Note: If you use "\ %" or "\ % _" in some body environments _", these will return strings "\ %" and "\ _" instead of "%" and "_".
★★
There are several methods to enclose quotation marks in a string:
1. Escape:
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.
At the same time, you can continue to use an escape character "\" to escape
2. Escape-free:
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.
Likewise,
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 ';
+ ------- + --------- + ----------- + -------- +
Please hello everyone "hello" everyone "" hello "" chela'lo then 'Hello everyone
+ ------- + --------- + ----------- + -------- +
Mysql> SELECT "hello", "'hello'", "'hello'", "El" "lo", "\" hello ";
+ ------- + --------- + ----------- + -------- +
When hello, then 'hello' then 'hel "lo done" hello
+ ------- + --------- + ----------- + -------- +
Mysql> SELECT "This \ nIs \ nFour \ nlines ";
+ -------------------- +
Else This
Is
Four
Lines
+ -------------------- +
★★
If you want to insert binary data into a BLOB column, the following characters must be represented by escape sequences:
NUL
ASCII 0. You should use '\ 0' (a backslash and an ASCII '0') to represent it.
ASCII 92, backslash. .
'
ASCII 39, single quotes. It is represented.
"
ASCII 34, double quotation marks. It is represented.