How to remove a single quote from a value while inserting in SQL database

扶醉桌前 提交于 2021-01-29 04:20:33

问题


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", ..), ...

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


回答1:


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.



来源:https://stackoverflow.com/questions/39052120/how-to-remove-a-single-quote-from-a-value-while-inserting-in-sql-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!