插入单引号 + 双引号 MySQL

Insert simple + double quote MySQL

考虑到这个 table

CREATE TABLE name
( nom VARCHAR(255))

我怎么能在我的 table

中插入一个带有简单 + 双引号的字符串,例如:'it's a "string"'
Insert into name values (`it's "string"`) 

这实际上不起作用。 感谢您的建议。

您可以使用 ' 作为字符串分隔符和反斜杠来转义特殊字符:

Insert into name values ('it\'s \"string\"') 

以下代码会对您有所帮助,

CREATE TABLE name
( nom VARCHAR(255));

set @str = "it\'s \"string\"";
insert into name values(@str);

您必须在单引号和双引号之前使用 \

Sql Fiddle Demo