不要太忙了 好好珍惜眼下 的真爱 (马晓静sorry~)
表 test
---------------
id | i_order
---------------
1 | 22
2 | 23
---------------
转换后结果为:
---------------
id | i_order
---------------
1 | 23
2 | 22
---------------
Oracle 和SQLServer数据语句相同,语句如下::
UPDATE test
SET i_order = (CASE
WHEN id = 1 THEN
(SELECT i_order FROM test WHERE id = 2)
WHEN id = 2 THEN
(SELECT i_order FROM test WHERE id = 1)
END)
WHERE id=1 OR id=2;