Link to home
Start Free TrialLog in
Avatar of Computer Guy
Computer Guy

asked on

MySQL Replace Syntax

Hi, I want to replace this ’ with ' in MySQL.

Table: songs
Field: name

This is what I have and It I get an error



SELECT REPLACE('name', '’', ''');

Any ideas?
Avatar of tigin44
tigin44
Flag of Türkiye image

SELECT REPLACE(name, '’', '''');
try

SELECT REPLACE('na’me', '’', "'"); // or
SELECT REPLACE("'name'", "'", "");

you also could escape characters SELECT REPLACE('na’me', '\’', "\'");

HTH

Ivo Stoykov
Avatar of Computer Guy
Computer Guy

ASKER

I need to put the table and field name in there too. So what is the syntax that way?
ASKER CERTIFIED SOLUTION
Avatar of Ivo Stoykov
Ivo Stoykov
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When I use PHP my admin, I need to specify what table and field I want to change too. I can't use escape characters for what I'm trying to do.

So this: SELECT REPLACE(tablename.columnname, '’', "'");

Will replace all ’

with this '

?

Thanks
yes, but ' (single quote) is a string delimiter so you should escape it
SELECT REPLACE(tablename.columnname, '’', "\'");

Open in new window


so REPLACE will replace quotes only inside the data of the column, but not in column name

HTH

Ivo Stoykov