如何在插入 SQL 数据库时从值中删除单引号 [英] How to remove a single quote from a value while inserting in SQL database

查看:99
本文介绍了如何在插入 SQL 数据库时从值中删除单引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一长串插入查询,其中有一个小错误.

I have a long list of insert query which has a slight error.

INSERT INTO `delivery_zip` (..) 
VALUES ("AB'C / DEF", ..), ("AB'C / DEF", ..), ("AB'C / DEF", ..), ...

如何从值中删除 AB' 之后的单引号.

How do I remove the single quote after AB' from the values.

推荐答案

如果有问题的单引号是唯一col1中的单引号,并且您已经插入了数据,那么你应该安全地使用 UPDATEREPLACE 来删除它:

If the single quote in question is the only single quote present in the column col1, and you have already inserted the data, then you should be safe using UPDATE with REPLACE to remove it:

UPDATE delivery_zip
SET col1 = REPLACE(col1, ''', '')

但如果您还没有完成插入,您可以先在脚本中进行查找和替换,如果需要,可能使用正则表达式.

But if you haven't done the insertion yet, you could do a find and replace in your script first, possibly using a regex if needed.

这篇关于如何在插入 SQL 数据库时从值中删除单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆