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?
Table: songs
Field: name
This is what I have and It I get an error
SELECT REPLACE('name', '’', ''');
Any ideas?
SELECT REPLACE(name, '’', '''');
try
SELECT REPLACE('na’me', '’', "'"); // or
SELECT REPLACE("'name'", "'", "");
you also could escape characters SELECT REPLACE('na’me', '\’', "\'");
HTH
Ivo Stoykov
SELECT REPLACE('na’me', '’', "'"); // or
SELECT REPLACE("'name'", "'", "");
you also could escape characters SELECT REPLACE('na’me', '\’', "\'");
HTH
Ivo Stoykov
ASKER
I need to put the table and field name in there too. So what is the syntax that way?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.columnna me, '’', "'");
Will replace all ’
with this '
?
Thanks
So this: SELECT REPLACE(tablename.columnna
Will replace all ’
with this '
?
Thanks
yes, but ' (single quote) is a string delimiter so you should escape it
so REPLACE will replace quotes only inside the data of the column, but not in column name
HTH
Ivo Stoykov
SELECT REPLACE(tablename.columnname, '’', "\'");
so REPLACE will replace quotes only inside the data of the column, but not in column name
HTH
Ivo Stoykov