0

I have 4 languages on my site, and 50 posts per language. In each of the 200 posts there is a custom field with the current value

Monday

Now I would like to update this custom field for my other languages (German, French, Spanish) with their respective translations of the word 'Monday'. So for the 50 German posts, the current value 'Monday' would be updated to

Montag

For the 50 French posts the custom field value would become

Lundi

And, last not least, for the 50 Spanish posts, the custom field value needs to be

Lunes

Now, instead of opening 150 tabs in my browser and manually update the custom field values via WP Admin, I'd like to run a MySQL query for each language to bulk update the values.

The "logic" of the query to update my German posts' custom field value would look something like that:

UPDATE 'wp_postmeta'
SET 'meta_value' = 'Montag'
 WHERE 'meta_value' = 'Monday'
AND 
 FROM TABLE 'wp_icl_locale_map' WHERE 'code' = 'de'

This is not working due to syntax errors and I'm not a MySQL expert.

halfer
  • 19,824
  • 17
  • 99
  • 186
bauhausweb
  • 135
  • 1
  • 13
  • [Possible duplicate](https://stackoverflow.com/questions/15209414/how-to-do-3-table-join-in-update-query). – halfer Jun 27 '17 at 17:13
  • I did a one hour google/stackoverflow search before posting my question but I didn't find anything - otherwise I would not have posted it in the first place. And I don't see the possible duplicity in your suggested link either. – bauhausweb Jun 27 '17 at 17:31
  • The possible duplicate shows how to update one table based on values in other joined tables. Isn't that what your SQL is trying to do? Or are you trying to update two tables in the same statement? – halfer Jun 27 '17 at 19:40
  • It seems like JOIN may indeed be what I'm looking for. When I stumbled across this term for the first time, I assumed it would mean "merge" (tables) and quickly skipped it therefor. Mea culpa! – bauhausweb Jun 28 '17 at 14:57
  • Ah, no problem. Let me know how you get on. I'll suggest it as a duplicate for now, but if you find it is not, please edit the question to describe how it is different. Thanks `:-)`. – halfer Jun 28 '17 at 15:42

0 Answers0