TomBomb
TomBomb

Reputation: 3296

MySQL query: update for set of keys

I know I've seen this syntax before, but I can't remember it/find it on here.

I want to write the condensed form of the following query:

UPDATE Users SET Activated = 1 WHERE ID = 1 OR ID = 2 OR ID = 3 OR ID = 4 OR...

There is a way to have the WHERE attribute be a set of values, something like:

UPDATE Users SET Activated = 1 WHERE ID IN_ARRAY(1, 2, 3, 4, ...)

Can anyone tell me the exact syntax?

Thank you!!

Upvotes: 1

Views: 680

Answers (2)

Max Hudson
Max Hudson

Reputation: 10206

Just lose the IN_ARRAY string and it will function

Upvotes: 0

mellamokb
mellamokb

Reputation: 56769

Yes, the keyword is IN:

UPDATE Users SET Activated = 1 WHERE ID IN (1, 2, 3, 4,...)
                                        ^^

Upvotes: 3

Related Questions