Difference between revisions of "Tricks and tips"
(→Permut two rows according to their id) |
|||
Line 1: | Line 1: | ||
=SQL= | =SQL= | ||
==Permut two rows according to their id== | ==Permut two rows according to their id== | ||
+ | Goal: permut two rows with id "a" and id "b" | ||
UPDATE some_table SET id = a + ABS(id - b) WHERE order_num in (a , b) | UPDATE some_table SET id = a + ABS(id - b) WHERE order_num in (a , b) |
Revision as of 21:16, 16 January 2007
SQL
Permut two rows according to their id
Goal: permut two rows with id "a" and id "b"
UPDATE some_table SET id = a + ABS(id - b) WHERE order_num in (a , b)