Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: Database Administration >> Update SQL Statement

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: Update SQL Statement
 Ratnaker  Posted: May 18, 2007 07:47:41 AM

 Total Post: 141
 Joined: Apr, 2007






 Hi,

I designed one table :

Contact

contID Code1 Code2
------ ----- ------
1 A B
2 A B
3 A B
4 A B

i want to update A to B and B to A in One Update Statement. Please give solution.

Ratnaker

 sudha
Posted: May 18, 2007 12:57:35 PM  

 Total Post: 15
 Joined: Jan, 2007






 
hi kp
update contact set code1 = 'B',code2 = 'A'
where code1 ='A' and code2 = 'B';

-Sudha

 Ratnaker
Posted: May 21, 2007 12:54:38 AM  

 Total Post: 141
 Joined: Apr, 2007






 
Hi Sudha,

Its very usefule for me.

Thank you very much

Ratnaker

 Ratnaker
Posted: May 21, 2007 01:36:01 AM  

 Total Post: 141
 Joined: Apr, 2007






 
Hi,

I designed one table :

Contact

contID Code1
------ -----
1 A
2 A
3 B
4 B

i want to update A to B and B to A in One Update Statement. Please give solution

 dipali
Posted: May 21, 2007 02:45:03 AM  

 Total Post: 35
 Joined: Dec, 2006






 
i don't think it's possible in one query..

 Ratnaker
Posted: May 29, 2007 07:04:30 AM  

 Total Post: 141
 Joined: Apr, 2007






 
Hi Sudha,dipali and all my forum friends
you can do. It is possible:

update t set code1 = decode( code1, 'A', 'B', 'B', 'A' ) where code1 in ( 'A', 'B' );


Ratnaker

 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Gopu Gopi333
  Gitesh Trivedi322
  Vinoth Kumar264
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software