0

Considering this table

CREATE TABLE name
( nom VARCHAR(255))

How could i insert a string with simple + double quote like : 'it's a "string"' inside my table

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

This doesn't work actually. Thanks for suggestions.

rSim
  • 344
  • 4
  • 17

2 Answers2

2

You can use ' as string delimiters and backslash to escape special chars:

Insert into name values ('it\'s \"string\"') 
kiks73
  • 3,718
  • 3
  • 25
  • 52
  • I knew about escaping, my problem was that I have many string from à cdv file. You are not really responding to my answer but you give me an idea. Thanks – rSim Mar 10 '18 at 09:08
  • Probably, you should edit your question then. I don't see anything about a "cdv file" in your question – Nico Haase Mar 10 '18 at 10:05
0

Following code will be helpful to you,

CREATE TABLE name
( nom VARCHAR(255));

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

You have to use \ before single and double quotes.

Sql Fiddle Demo

Abhilash Ravindran C K
  • 1,818
  • 2
  • 13
  • 22