转载地址:http://yefengyuhongwei.blog.163.com/blog/static/21070682007115112726390/
sql语句插入的数据中含有单引号怎么办?
sql中,insert into yourTable(col1,col2) values(2,'abc')
字符串数据是用单引号包在外面的,如果插入的数据中包含单引号,就需要处理,你可以将单引号替换成两个单引号,在sql中连续两个单引号就表示一个单引号字符,例如
insert into yourTable(col1,col2) values(2,'ab''c')表示插入
新记录 col2 字段为ab'c
使用函数replace可以实现这个功能:
replace(Str1,"'","''")