sql - Swapping column values in Oracle -


I was solving one of the puzzles and using switched column values, using DML questions:

  from SEEM + TEMP_TABLE; ID 1, ID 2 -------- 20, 15 20, 15 20, 15   

The solution is mathematical calculation:

  update Templable set ID1 = ID1 + ID2; Update temp set ID2 = ID1-ID2; Update templates SET ID1 = ID1-ID2;   

Now, I am trying to figure out whether it can be applied to strings or not, please suggest.

  SELECT * to TEMP_TABLE_NEW; ID 1, ID2 -------- ABC, XYZ ABC, XYZ ABC, XYZ    

There is no need to have three update statements; one is enough:

  UPDATE temp_table_new SET id1 = id2, id2 = id1;    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -