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,253
  • 3
  • 18
  • 36
pallavi_ios
  • 107
  • 1
  • 2
  • 12

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,253
  • 3
  • 18
  • 36
Techy
  • 2,406
  • 7
  • 37
  • 82
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
  • 11,992
  • 4
  • 23
  • 40