robertgombos robertgombos - 6 months ago 30
MySQL Question

How to update multiple values for specific ID numbers

I have a website and I want to update some empty values for some IDs.

In phpMyAdmin, editing a single row gives me this result:

UPDATE `sample_dir`.`page` SET `votes` = '4', `rating` = '7.00'
WHERE `page`.`id` =12676170;

However, if I try to update multiple rows at once (I was thinking putting a comma between the IDs will do it but it doesn't). I used this sql command:

UPDATE "sample_dir`.`page` SET `votes` = '1', `rating` = '9.00'
WHERE `page`.`id` =2042085451,12676170,733543897;

What am I doing wrong?



Use the IN() operator

UPDATE  `sample_dir`.`page` SET  `votes` =  '1', `rating` =  '9.00'
WHERE  `page`.`id` IN (2042085451,12676170,733543897);