If I have a table T with 4 rows & 2 columns A & B. A has
values 1,2,3,4. and B has 10,20,30,40. Write an Update SQL
query which can Swap the values of A & B for all records.
(Do not use a sub-query)
Answers were Sorted based on User's Feedback
Answer / bunty
UPDATE T
SET A = B,B=A;
I am surprized but above query will fetch the desired
result.
Cheers,
Bunty
Is This Answer Correct ? | 30 Yes | 1 No |
Answer / lova raju allumalla
update T set A=B,B=A where A in (select A from T);
Is This Answer Correct ? | 1 Yes | 2 No |
How does cross join work in sql?
Is left join same as join?
Does sql use python?
Is sql scripting language?
Why having clause is used in sql?
how can we destroy the cookie? : Sql dba
how would you enter characters as hex numbers? : Sql dba
find the third highest salary?
what is the difference between truncate and delete statement? : Transact sql
What is record variable?
What is difference between mysql and postgresql?
Is sql developer case sensitive?