robertgombos
robertgombos

Reputation: 27

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?

Thanks

Upvotes: 0

Views: 135

Answers (1)

mituw16
mituw16

Reputation: 5250

Use the IN() operator

http://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#function_in

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

Upvotes: 2

Related Questions