Title: Need help with simple MySQL query
Tags: mysql
Question: I have a table with 4 values, meta_id, post_id, meta_key and meta_value, and I want to change all meta_values found as "yes" to "si" when the meta_key is stock_available... how do I do this?. I cannot even retrieve the rows at this point...I'm trying with something like this.
SELECT `meta_value` FROM `wp_postmeta` WHERE `meta_key` AND `meta_value` = 'yes'
Could I have some help?
EDIT: I had forgotten the meta_key...
SELECT * FROM `wp_postmeta` WHERE `meta_key` = 'stock_available' AND `meta_value` =  yes'
So I retrieve these... btu how do I update them?
Comment: You must provide a condition for 'meta_key', for example
`SELECT meta_value FROM wp_postmeta WHERE meta_key = 'somekey' AND meta_value = 'yes'`

Here is the accepted answer: You need to use the SQL UPDATE statement:
UPDATE wp_postmeta SET meta_value = 'si' WHERE meta_value = 'yes' AND meta_key = 'stock_available'
Before you do that, run this SELECT to make sure that you are going to be updating the correct rows:
SELECT * FROM wp_postmeta WHERE meta_value = 'yes' AND meta_key = 'stock_available'
Comment for this answer: that was it, thanks a lot... I need 11 minutes to accept the answer. I'llbe back then

Here is another answer: UPDATE wp_postmeta
SET meta_value = 'si'
WHERE meta_key = 'stock_available'
AND meta_value = 'yes';

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2011:00:07/19/11', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<mysql>', 'Title': 'Need help with simple MySQL query', 'ViewCount': 59, 'id': 6749613, 'user_AboutMe': '', 'user_AccountId': 385034.0, 'user_DisplayName': 'la_f0ka', 'user_Reputation': 1733.0, 'user_Views': 164.0, 'user_id': 741933.0}}