Reputation: 13
I'm attempting to change the following row "forum_id" in my "topics" table to reflect as 1069 if the original id is greater than 1400.
However, I'd like to exclude all the numbers below in parentheses from the changes, as they would be included in the original query but I wish to protect them from change.
Is this the best way to do this, or is there another way?
UPDATE topics
SET forum_id =
CASE
WHEN forum_id>1400
AND forum_id !=(3761,3762,3962,3749,2909,1917,1919,1891,3056,1415,4690,1427,1428,3677,3809,1425,1426,4465,4466,3810,1534,1535,1413,4402,3808,1453,1459)
THEN 1069
ELSE forum_id
END
Upvotes: 0
Views: 21
Reputation: 14666
Look closer at the UPDATE syntax
UPDATE topics
SET forum_id= 1069
WHERE forum_id > 1400
AND forum_id NOT IN (3761,3762,3962,3749,2909,1917,1919,1891,3056,1415,4690,1427,1428,3677,3809,1425,1426,4465,4466,3810,1534,1535,1413,4402,3808,1453,1459)
Upvotes: 3