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 |
what are the advantages and disadvantages of views in a database? : Sql dba
What are different types of sql?
What are different sql data types?
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)
Why do we use sqlite?
What is posting?
What is a loop in sql?
explain primary keys and auto increment fields in mysql : sql dba
What is the difference between inner join and left join?
how to create user in sql and how to set password for that?
HP Interview -2016 Unix 1) grep command in unix 2) what is set command
what are all different types of collation sensitivity? : Sql dba