Reputation: 281
When I run this sql command:
UPDATE chat_data
SET message = replace(message, '\', '')
LIMIT 1 ;
It gives me syntax error:
13:07:46 UPDATE chat_data SET message = replace(message, '\', '') LIMIT 1 ; Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''\', '') LIMIT 1' at line 1 0.237 sec
Any solution for this ?
Upvotes: 0
Views: 12644
Reputation: 27
If you want to replace visible backslash (\) with sql you could also use
REPLACE(message, CHAR(92), '')
Upvotes: 0
Reputation: 446
I had a case today on a legacy project. Here is a solution for a SELECT statement :
'SELECT * FROM my_table WHERE label = REPLACE("'.mysql_real_escape_string($label).'", "'.mysql_real_escape_string('\\').'", "")'
Upvotes: 0
Reputation: 49049
You need to escape the \
character:
UPDATE chat_data SET message = replace(message, '\\', '') LIMIT 1 ;
Upvotes: 6