Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace escape character with a string

Tags:

replace

mysql

I am trying to replace escape character with a string but the query is giving me an irrelevant result

eg- char- '\' replace with 'adfc' with below query

SELECT REPLACE("abcdefgh\i","\\", "adfc" );

output - abcdefghi

Desired output - abcdefghadfci

How can i achieve this in mysql?

like image 885
vivek kumar singh Avatar asked Oct 31 '22 09:10

vivek kumar singh


1 Answers

in your my.ini add this line:

sql-mode="NO_BACKSLASH_ESCAPES"

then restart your mysql server, and replace your query with this:

SELECT REPLACE("abcdefgh\i","\", "adfc" );

reference here

like image 173
Gouda Elalfy Avatar answered Nov 15 '22 06:11

Gouda Elalfy