WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For all the "price" custom fields of a site, the dollar sign was entered with the value. I need to remove the dollar sign and leave the just the values.

I know very little about SQL queries. The values are all different, so I was hoping I could use UPDATE and the wildcard to effectively delete the dollar sign, but alas, I can't make it happen.

This is what I'm trying to achieve

UPDATE wp_postmeta SET meta_value = replace(meta_value, '$%', '%') WHERE meta_key LIKE 'price'.

share|improve this question
I do not know that from the top of my head, but I'm sure you can look that up in the MySQL manual: dev.mysql.com/doc/refman/5.5/en – hakre Jan 10 '11 at 15:47
Are you trying to update all instances of the meta_value for all posts? Or is this something that happens within a theme/plugin? – sanchothefat Jan 10 '11 at 16:16
Additional note: If you're adding in the currency you'd be better off using another custom field for it, just in case you wanted extra currencies some day. – sanchothefat Jan 10 '11 at 18:37

Why doesn't this work?

UPDATE wp_postmeta 
SET meta_value = REPLACE( meta_value, '$', '' ) 
WHERE meta_key LIKE 'price';
share|improve this answer
Maybe it will work goldenapples. So that will simply stip the dollar sign and leave the rest of the value? – flippWP Jan 14 '11 at 23:36
Yeah, it should. No reason to leave a wildcard in there (and I don't think you can use a wildcard in the replace field) – goldenapples Jan 14 '11 at 23:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.