2

I have Sql database with table name QUESTION.

I want to insert value for QuestionTitle as html string. Insert query is

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>")

When I try to execute this query in Sql it gives an error . How can I do this so that it will work for html string.

Charlesliam
  • 1,293
  • 3
  • 20
  • 36
pallavi_ios
  • 107
  • 1
  • 3
  • 13

2 Answers2

4

You have error in using " inside the third inserted value

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>'
       );

You can also use escape slashes

Charlesliam
  • 1,293
  • 3
  • 20
  • 36
Techy
  • 2,626
  • 7
  • 41
  • 88
0

Try somthiung like this:-

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>');

Hope this helps you.

Ankit Bajpai
  • 13,128
  • 4
  • 25
  • 40