SQL插入中的单引号和双引号问题

时间:2012-05-30 14:44:58

标签: ios sql database sqlite

请参阅下面的查询。

INSERT INTO pro VALUES ("260915",'Peel and Stick Floral Wall Art','Transform your tot's bedroom into a bright, burgeoning meadow with this set of oh-so-colorful wall art. Each unique flower, bird, butterfly, and swirly sun is a colorful creation of multilayered vinyl brimming with life and energy. How best to arrange them is entirely up to you--and your 12.2" x 15.4"','','Shipping',"790","110-m4jlgu36n",1.00,0,0,"0.00","70.00","http://.com/peel-and-stick-floral-wall-art.html","622")

这里我有单引号和双引号,我想在一列中插入相同的值:

eg a) 12.2" x 15.4"
   b) Transform your tot's 

请提出最佳解决方案。

5 个答案:

答案 0 :(得分:2)

构建INSERT时,在外部使用单引号,双引号问题就解决了。

要解决单引号问题,请将'替换为''

答案 1 :(得分:0)

为什么你不逃避你的报价? 12.2\"

答案 2 :(得分:0)

将所有内容放在单引号'

'12.2" x 15.4"<br>'

对于像Transform your tot's这样的字符串,你必须像

一样逃避它
'Transform your tot\'s'

答案 3 :(得分:0)

对于T-SQL,要在数据中获取单引号,只需将其与另一个引用(例如,使用彼此相邻的两个单引号)。您不必担心字符串文字中的双引号。

INSERT INTO foo VALUES ('qwerty''s: 25" sq.')

答案 4 :(得分:0)

仅使用单引号(')来包围值。如果单个引号是值的一部分,请键入两次(这是逃避它的方式)。

E.g。

INSERT INTO TABLE VALUES ('12.2" x 15.4"', 'Transform your tot''s bedroom...');