Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / nanne saheb c

Assume that the sample table is as below
X Y
------------
1 3
2 4

Update sample set
X=decode(X,1,3,2,4),
Y=decode(Y,3,1,4,2);

(OR)
Update sample set
X = (case when 1 then 3
when 2 then 4
end),
Y = (case when 3 then 1
when 4 then 2
end);

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between union and union all command?

1151


explain advantages of innodb over myisam. : Sql dba

1175


how to use in conditions? : Sql dba

1059


How do I turn a list into a table?

1008


What is trigger and stored procedure in sql?

1092


What is rownum?

1034


What is a constraint? Tell me about its various levels.

1246


What is the use of double ampersand (&&) in sql queries? Give an example

1187


What is self-join and what is the requirement of self-join?

1190


is it possible to pass an object or table to a procedure as an argument?

1176


define sql delete statement ? : Sql dba

1068


What are the dml statements?

1196


Can we use join in subquery?

1150


How many sql are there?

1049


How do you know if a relationship is 2nf?

994