About
Pricing
Community
Teams
Start Free Trial
Log in
Computer Guy
asked on
7/5/2012
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?
MySQL Server
Databases
6
1
Last Comment
Ivo Stoykov
8/22/2022 - Mon
tigin44
7/5/2012
SELECT REPLACE(name, '’', '''');
Ivo Stoykov
7/5/2012
try
SELECT REPLACE('na’me', '’', "'"); // or
SELECT REPLACE("'name'", "'", "");
you also could escape characters SELECT REPLACE('na’me', '\’', "\'");
HTH
Ivo Stoykov
Computer Guy
7/6/2012
ASKER
I need to put the table and field name in there too. So what is the syntax that way?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Ivo Stoykov
7/7/2012
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Computer Guy
7/13/2012
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
Ivo Stoykov
7/13/2012
yes, but ' (single quote) is a string delimiter so you should escape it
SELECT REPLACE(tablename.columnname, '’', "\'");
Select all
Open in new window
so REPLACE will replace quotes only inside the data of the column, but not in column name
HTH
Ivo Stoykov