在MySQL中,当我尝试在表中插入反斜杠时,它不接受它,并为我提供了没有反斜杠的内容。
id 设置为自动递增:
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转义的所有字符的列表)