Tricks and tips

Revision as of 21:16, 16 January 2007 by Claratte (Talk | contribs) (Permut two rows according to their id)

Jump to: navigation, search

SQL

Permut two rows according to their id

Goal: permut two rows with id=a and id=b using only one query

UPDATE some_table SET id = a + ABS(id - b) WHERE order_num in (a , b)