MySQL没有插入反斜杠 [英] MySQL is not inserting a backslash

查看:546
本文介绍了MySQL没有插入反斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MySQL中,当我尝试在表中插入反斜杠时,它不接受它,并为我提供了没有反斜杠的内容.

In MySQL, when I try to insert a backslash into my table, it does not accept it and gives me the content without the backslash.

id设置为自动递增:

代码:

INSERT INTO gender (sex, date) VALUES (
'male are allowed \ female are not allowed', "2012-10-06")

如何插入文字反斜杠?

有关转义序列的注释:

Escape  Sequence    Character Represented by Sequence

\0     An ASCII NUL (0x00) character.
\'     A single quote ("'") character.
\"     A double quote (""") character.
\b     A backspace character.
\n     A newline (linefeed) character.
\r     A carriage return character.
\t     A tab character.
\Z     ASCII 26 (Control+Z). See note following the table.
\\     A backslash ("\") character.
\%     A "%" character. See note following the table.
\_     A "_" character. See note following the table.

推荐答案

您需要转义反斜杠:

INSERT INTO gender
(sex, date) VALUES (
'male are allowed \\ female are not allowed',
"2012-10-06")

参考(带有必须转义的所有字符的列表) mysql)

这篇关于MySQL没有插入反斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆