Home » SQL & PL/SQL » SQL & PL/SQL » How to join 2 update statements
How to join 2 update statements [message #424349] Thu, 01 October 2009 12:29 Go to next message
lamnguyen14
Messages: 119
Registered: March 2007
Location: Virginia
Senior Member
Hi.

I have 2 update statements like below. Would you please to show me if there is any way I can join them in one statement? I would appreciate that.

UPDATE emp a 
SET salary = '9999'
WHERE id = (SELECT id FROM emp1 b
            WHERE a.ID = b.id AND b.status = '0');
    
UPDATE emp a 
SET salary = '8888'
WHERE id = (SELECT id FROM emp1 b
            WHERE a.ID = b.id AND b.status = '1');



Thank you very much.
LN
Re: How to join 2 update statements [message #424350 is a reply to message #424349] Thu, 01 October 2009 12:49 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
A single update statement with a decode or case statement would do the trick. something like
update emp a set salary = (select decode(status,0,...


Are you really storing salary as a character string?

[Updated on: Thu, 01 October 2009 12:53]

Report message to a moderator

Re: How to join 2 update statements [message #424351 is a reply to message #424349] Thu, 01 October 2009 12:52 Go to previous message
lamnguyen14
Messages: 119
Registered: March 2007
Location: Virginia
Senior Member
Thanks much.
Previous Topic: VARCHAR2 problem
Next Topic: Difference between Varchar2/Char and CLOB
Goto Forum:
  


Current Time: Tue Dec 03 18:12:40 CST 2024