there are 2 variables called x and y ,x contains 1,2 and y
contains 3,4 we have to swap the values from x to y and y
to x with out using dummy variables and it can be done only
by using a single statement ? how?

Answer Posted / ravin

Buddies, why are you all selecting from and updating the
tables. The question says, just two variables to be swapped
without using any extra variable and also with a single
statement.
And Ramakanth's answer is right i.e. y=x+y-(x=y) . Thats it.

^^x contains 1,2 - didn't understand though.

Is This Answer Correct ?    13 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

when MSQL8.0 is in market

1596


Is sql similar to python?

535


What is the usage of the distinct keyword?

682


What are types of indexes in sql?

537


what is index? : Sql dba

556






What is type and rowtype in pl sql?

535


What is the difference between a database and a relational database?

558


What are different types of sql commands?

508


How show all rows in sql?

608


how to start mysql server? : Sql dba

609


what are date and time functions in mysql? : Sql dba

532


how would you write a query to select all teams that won either 2, 4, 6 or 8 games? : Sql dba

768


Why do we need pl sql?

548


What is write ahead logging in sql server?

561


What is plpgsql language?

529