在SQL中插入HTML字符串查询

时间:2014-06-26 06:29:41

标签: mysql sql sql-server

我有一个表名为QUESTION的Sql数据库。

我想将QuestionTitle的值插入为html字符串。 插入查询是

INSERT INTO 
   QUESTION (QuestionType,QuestionID,QuestionTitle) 
VALUES ("MRQ",
        "QNB5T6TKDMS",
        "<p><span style="font-family: comic sans ms,sans-serif; font-size: 
small;">what was the original concentration of the acid?</span></p>")

当我尝试在Sql中执行此查询时,它会出错。 我该怎么做才能使它适用于html字符串。

2 个答案:

答案 0 :(得分:2)

在第三个插入值

中使用"时出错
INSERT INTO 
   QUESTION (QuestionType,QuestionID,QuestionTitle) 
VALUES ('MRQ',
        'QNB5T6TKDMS',
        '<p><span style="font-family: comic sans ms,sans-serif; font-size: small;">
         what was the original concentration of the acid?</span></p>'
       );

您也可以使用转义斜杠

答案 1 :(得分:0)

尝试这样的somthiung: -

INSERT INTO QUESTION (QuestionType,QuestionID,QuestionTitle) VALUES 
('MRQ','QNB5T6TKDMS','<p><span style="font-family: comic sans ms,sans-serif; font-size: 
small;">what was the original concentration of the acid?</span></p>');

希望这会对你有所帮助。