Issue
here i want to change the date for 9 rows
1.
UPDATE forum_topic_resume
SET _When_Updated = (now() -INTERVAL 6 day)
WHERE _id IN (96250, 69081, 69555)
UPDATE forum_topic_resume
SET _When_Updated = (now() -INTERVAL 8 day)
WHERE _id IN (70494, 68612, 69564, 69660, 72437, 80498)
The change the status
3.
UPDATE forum_topic_resume
SET _Status = 1224
WHERE _id IN (96250, 69081, 69555)
UPDATE forum_topic_resume
SET _Status_Is = 1228
WHERE _id IN (70494, 68612, 69564)
UPDATE forum_topic_resume
SET _Status_Is = 1229
WHERE _id IN (69660, 72437, 80498)
There are about 52 more Ids for whom I was to set the status to a different value which would look like below.
6.
UPDATE forum_topic_resume
SET _Status_Is = 1250
WHERE _id IN (for the rest of the ids)
Solution
One way is using multiple case conditions:
UPDATE forum_topic_resume
SET _When_Updated = CASE
WHEN _id IN (96250, 69081, 69555) THEN (now() -INTERVAL 6 day)
WHEN _id IN (70494, 68612, 69564, 69660, 72437, 80498) THEN (now() -INTERVAL 8 day)
other id conditions .............
END,
_Status = CASE
WHEN _id IN (96250, 69081, 69555) THEN 1224
WHEN _id IN (70494, 68612, 69564) 1228
......
END,
_Status_Is = CASE
WHEN _id IN (96250, 69081, 69555) THEN 1224
WHEN _id IN (70494, 68612, 69564) 1228
......
END;
Answered By - Ergest Basha Answer Checked By - Gilberto Lyons (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.