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

what are the advantages and disadvantages of views in a database? : Sql dba

0 Answers  


What are different types of sql?

0 Answers  


What are different sql data types?

0 Answers  


I have 2 Databases. How can create a table in particular database? How can i know the list of tables presented each database?( in oracle 10g)

5 Answers   Relq,


Why do we use sqlite?

0 Answers  






What is posting?

0 Answers  


What is a loop in sql?

0 Answers  


explain primary keys and auto increment fields in mysql : sql dba

0 Answers  


What is the difference between inner join and left join?

0 Answers  


how to create user in sql and how to set password for that?

3 Answers  


HP Interview -2016 Unix 1) grep command in unix 2) what is set command

1 Answers   HCL,


what are all different types of collation sensitivity? : Sql dba

0 Answers  


Categories