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



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..

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

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..

Answer / avi007

select A as "B",B AS "A" from T;

Is This Answer Correct ?    1 Yes 2 No

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..

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

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..

Answer / amit

UPDATE T
SET A = B, ENVDOR_NUMBERB = A

Is This Answer Correct ?    1 Yes 4 No

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..

Answer / preeti mishra

update T
set A:=A+B,
B:=A-B,
A:=A-B;

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More SQL PLSQL Interview Questions

How does cross join work in sql?

0 Answers  


Is left join same as join?

0 Answers  


Does sql use python?

0 Answers  


Is sql scripting language?

0 Answers  


Why having clause is used in sql?

0 Answers  






how can we destroy the cookie? : Sql dba

0 Answers  


how would you enter characters as hex numbers? : Sql dba

0 Answers  


find the third highest salary?

23 Answers  


what is the difference between truncate and delete statement? : Transact sql

0 Answers  


What is record variable?

0 Answers  


What is difference between mysql and postgresql?

0 Answers  


Is sql developer case sensitive?

0 Answers  


Categories