Exempel:byt doc_num mot id 2 och 4:
UPDATE tbl dst
SET doc_num = src.doc_num
FROM tbl src
WHERE dst.id IN(2,4)
AND src.id IN(2,4)
AND dst.id <> src.id -- don't try this at home!
;
SELECT * FROm tbl
ORDER BY id;
Resultat:
id | doc_num | doc_text
----+---------+--------------------
1 | 1 | First column text1
2 | 3 | First column text2
4 | 2 | First column text3
7 | 4 | First column text4
(4 rows)