Mysql字符转义


执行该语句报错:
update remoteorder t set  t.greetings = 'Hope's' where t.orderid = 1640000 and t.greetings is null;

采用转义字符解决:
update remoteorder t set  t.greetings = 'Hope\'s' where t.orderid = 1640000 and t.greetings is null;

在字符串中,某些序列具有特殊含义。这些序列均用反斜线(‘\’)开始,即所谓的转义字符。MySQL识别下面的转义序列:

\0

ASCII 0(NUL)字符。

\'

单引号(‘'’)。

\"

双引号(‘"’)。

\b

退格符。

\n

换行符。

\r

回车符。

\t

tab字符。

\Z

ASCII 26(控制(Ctrl)-Z)。该字符可以编码为‘\Z’,以允许你解决在Windows中ASCII 26代表文件结尾这一问题。(如果你试图使用mysql db_name < file_name,ASCII 26会带来问题)。

\\

反斜线(‘\’)字符。

\%

‘%’字符。参见表后面的注解。

\_

‘_’字符。参见表后面的注解。

请使用浏览器的分享功能分享到微信等