UPDATE forum_discussions SET category_id=70 WHERE category_id IN(1,2,3,4,5);
UPDATE forum_discussions SET category_id=71 WHERE category_id IN(6,7,8,9,10);
UPDATE forum_discussions SET category_id=72 WHERE category_id IN(11,12,13);
我想在一个批处理查询中编写这3个查询,以便像Codeigniter中的$ this-> db-> insert_bacth()更新。
有什么想法吗?
我尝试的方式与贝娄相似,但无法看到CI的成功。
UPDATE forum_discussions
SET cetgory_id = CASE category_id
WHEN 27 THEN 70
WHEN 65 THEN 71
WHEN 35 THEN 71
WHEN 31 THEN 72
WHEN 21 THEN 72
WHEN 23 THEN 72
WHEN 41 THEN 72
WHEN 42 THEN 72
WHEN 51 THEN 72
WHEN 63 THEN 72
WHEN 2 THEN 72
WHEN 3 THEN 73
WHEN 7 THEN 73
WHEN 15 THEN 73
WHEN 37 THEN 73
WHEN 11 THEN 73
WHEN 13 THEN 73
WHEN 17 THEN 73
WHEN 59 THEN 73
WHEN 69 THEN 73
WHEN 5 THEN 74
WHEN 29 THEN 74
WHEN 33 THEN 74
WHEN 61 THEN 74
WHEN 49 THEN 75
WHEN 67 THEN 75
END
WHERE category_id < 70