How to replace all double quotes to single quotes using mysql replace?

DEVOPS picture DEVOPS · Nov 18, 2011 · Viewed 33.5k times · Source

I need to replace all double quotes to single quotes using mysql query.

How can I do that. My sql should be in double quotes.

mysql="select replace(text,'\"',''') from mytable"

throwing error. How can I escape that single quotes inside query?

Answer

Shakti Singh picture Shakti Singh · Nov 18, 2011

Try this one

 $mysql="select replace(text,'\"',\"'\") from mytable";

Then the query will become

select replace(text,'"',"'") from mytable

at the Mysql end.