Update replace semicolon in SQL gets syntax error

我怕爱的太早我们不能终老 提交于 2020-06-17 04:25:50

问题


I import an SQL file to my database but there is something wrong. All punctuation at the end of a sentence/phrase have extra space.

Example:

This is a sentence .
This , as you can see , is a problem .
Do it !

Should be:

This is a sentence.
This, as you can see, is a problem.
Do it!

To correct, I am planning to run SQL commands on phpMyAdmin in this context

UPDATE book SET content = REPLACE(content,' .','.');
UPDATE book SET content = REPLACE(content,' ,',',');
UPDATE book SET content = REPLACE(content,' ?','?');
UPDATE book SET content = REPLACE(content,' !','!');
UPDATE book SET content = REPLACE(content,' :',':');

So far so good. But When I tried it on a semicolon like this

UPDATE book SET content = REPLACE(content,' ;',';');

I get syntax error #1064 when I simulate the query.

I tried escaping it with a backslash like this but same error

UPDATE book SET content = REPLACE(content,' \;','\;');

Any idea how to resolve this?

Thanks


回答1:


Try

delimiter /
UPDATE book SET content = REPLACE(content,' ;',';');
delimiter ;

EDIT:

It was a field in phpMyAdmin which is set to semicolon by default. Set on /.



来源:https://stackoverflow.com/questions/55816889/update-replace-semicolon-in-sql-gets-syntax-error

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