Reputation: 737
I have a table with 3 columns - key, valid and admin. I want to update the valid column of three rows - key IN (1,2,3). Now, I want to update it to 1 for all of them except the ones that have admin = 1. I thought something like this (not correct, just to show what I would like):
UPDATE table SET valid = 1
WHERE key IN (1,2,3)
AND key NOT IN(
SELECT key from table
WHERE admin = 1
)
Any idea? Thanks.
Upvotes: 0
Views: 673
Reputation: 46903
Don't overthink the problem.
update
table
set
valid = 1
where
key in (1,2,3)
and admin != 1
Upvotes: 1