Swapping column values in Oracle

前端 未结 3 1629
再見小時候
再見小時候 2021-02-19 10:25

I was solving one of the puzzles and came across swapping column values using DML queries:

SELECT * FROM TEMP_TABLE;
ID1, ID2
--------
20, 15
20, 15
20, 15
         


        
3条回答
  •  无人及你
    2021-02-19 11:04

    There's no need to have three update statements, one is sufficient:

    UPDATE temp_table_new 
    SET    id1 = id2, 
           id2 = id1; 
    

提交回复
热议问题