Reputation: 3882
I have a query that seems to work:
UPDATE questions SET active=TRUE WHERE id=ANY ([1, 5, 7]);
But I also want to set all other rows to active=FALSE
Essentially, I want to do the equivalent of running these two lines
UPDATE questions SET active=FALSE;
UPDATE questions SET active=TRUE WHERE id=ANY ([1, 5, 7]);
But I would like to accomplish this in a single query if possible. Is there a way to do this?
Upvotes: 0
Views: 59
Reputation: 121624
Use the condition as a Boolean value to set:
UPDATE questions SET active = (id = ANY(array[1, 5, 7]));
Upvotes: 2