update a group of users id
I have a long list of user information (userid, username, password and level) Now I wish to update a large number of user's level but I don't want to do that by a single command for each of the users. Is there a way to update all of them at once ? Thank you.
Use MySQL's IN() function in your WHERE statement to include all of the IDs you wish to update.
UPDATE users SET level=1 WHERE id IN(1,2,3,4,5);
Or, if everyone shares a common unique value in a column, you can use that instead. For example, if you wanted to update everyone at level 1 to go to level 2:
UPDATE users SET level=2 WHERE level=1;