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 can i read files from a pl/sq l program
What does the hierarchical profiler does?
What is the sql query to display the current date?
How do you respond to dementia behavior?
Is mariadb a nosql database?
write a query to display diference between two dates in sql server
what is 'force view'?
How to create a view on a table which does not exists
table - new_no old_no 2345 1234 3456 2345 5678 4567 output sud be -new_no 1234 2345 3456 4567 5678
How do I tune a sql query?
Can a view be mutating? If yes, then how?
Which is faster subquery or join?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)