问题
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