GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 112 of 171    Print  
I have a table with a column city. The values are “delhi” and “hyderabad”. I need to update Hyderabad with delhi and delhi with Hyderabad. Define a query for that

  
Total Answers and Comments: 5 Last Update: March 05, 2009     Asked by: surender reddy g 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
January 29, 2007 07:23:11   #1  
Ajay Nerumati Member Since: January 2007   Contribution: 3    

RE: I have a table with a column city. The values are...
you need three update statements for acheiving this task1. update set 'delhi' where 'temp' ;commit;2. update set 'delhi' where 'hyderabad' ;commit;3. update set 'hyderabad' where 'temp' ;commit;Please note that the commit is only a precaution it can be used only once after all the three DML statements are run.Thank you Ajay NerumatiOracle DBA
 
Is this answer useful? Yes | No
February 04, 2007 07:16:56   #2  
jkreddy        

RE: I have a table with a column city. The values are...
Hi its simple update statement.. update column city set city 'delhi' where city 'hyderabad'this is it simple...bye JK
 
Is this answer useful? Yes | No
February 10, 2007 00:58:24   #3  
rams        

RE: I have a table with a column city. The values are...
hitry out the following queryupdate tablenameset city case city when 'delhi' then 'hyderabad' when 'hyderabad' then 'delhi' else city end;
 
Is this answer useful? Yes | No
March 27, 2007 04:55:09   #4  
P.V.Deshpande        

RE: I have a table with a column city. The values are...
update table_city set city (decode(city 'Delhi' 'Hydrabad' 'Delhi'))
 
Is this answer useful? Yes | No
March 05, 2009 01:28:12   #5  
sharmasl Member Since: March 2009   Contribution: 10    

RE: I have a table with a column city. The values are “delhi” and “hyderabad”. I need to update Hyderabad with delhi and delhi with Hyderabad. Define a query for that
Update States set city decode(city `Delhi` `Hyderabad` `Hyderabad` `Delhi` city);

By using this query we can inter change the citys.

Thanks
Salil Sharma

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape