We help IT Professionals succeed at work.

Update MySQL field to change smart quote to straigth quote

Victor Kimura
Victor Kimura used Ask the Experts™
on
Hi,

I have some fields in a table products which has some smart quotes (from Microsoft Word) in them and the smart quotes don't work well with Javascript. So is there a fast way to update the smart quotes and change them to straight quotes using MySQL only. I know I can do this with PHP but I'd like to see the code for doing it with MySQL code only.

I can do this and  receive 30 rows:
SELECT products.product_descr
     , products.short_description
     , products.product_active_ingr
     , products.product_actives
     , products.product_id
     , products.product_name
FROM
  products
WHERE
  products.product_descr LIKE '%’%'
  OR products.short_description LIKE '%’%'
  OR products.product_active_ingr LIKE '%’%'
  OR products.product_actives LIKE '%’%'

Open in new window


But I need a update one. For instance, the field product_descr contains this:
Able to hold skin’s moisture in balance through stressful shifts in humidity, like steamy exteriors and interiors parched by air conditioning. Never go thirsty again.

Notice the smart quote in skin's.

Thank you,
Victor

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Expert of the Quarter 2010
Expert of the Year 2010
Commented:
Update products set
    product_descr = REPLACE(product_descr, '’', ''''),
    short_description = REPLACE(short_description, '’', ''''),
    product_active_ingr = REPLACE(product_active_ingr, '’', ''''),
    product_actives = REPLACE(product_actives, '’', '''')
WHERE
  products.product_descr LIKE '%’%'
  OR products.short_description LIKE '%’%'
  OR products.product_active_ingr LIKE '%’%'
  OR products.product_actives LIKE '%’%'
Victor KimuraSEO, Web Developer

Author

Commented:
Thank you.