Trying to replace a single backslash in a large db. Was going to run an Update Replace query on one column, but I can't figure out how to replace a single backslash. There was some poor updates done and these slashes need to be changed to another character, they are not escaping anything and do not perform any relevant function.
SELECT
REPLACE (
"Some\s string\s with slashe\s",
'\\',
' something '
)
When I run this, the output is: "Somes strings with slashes"
Is there any way to do a true replace on a single slash? No matter what I put in the replace parameter, it just eliminates the single backslash, but doesn't actually replace it. Not sure if this is a bug or I'm just missing something.
I have tried:
SELECT
REPLACE (
"Some\s string\s with slashe\s",
'\',
' something '
)
and I get:
[Err] 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 '\')' at line 1
REPLACE( )
doesn't need to be escaped
select replace("Some\s string\s with slashe\s", '\\', ' something ');
UPDATE 1
I think you want to permanently replace it. Right? Use UPDATE
not SELECT
UPDATE tableName
SET columnName = replace(columnName, '\\', '#');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With