Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.oracle -> Update rows when in other table

Update rows when in other table

From: elziko <elziko_at_NOTSPAMMINGyahoo.co.uk>
Date: Wed, 26 May 2004 10:51:32 +0100
Message-ID: <40b468a8$0$7727$afc38c87@news.easynet.co.uk>


I have two tables TAB_A and TAB_B. I want to update COL_1 in TAB_A to a certain value but only for rows where the value COL_2 in TAB_A is also found in COL_2 of TAB_B.

This is what I have but it seems to then set COL_1 of TAB_A to a NULL if its not found in TAB_B. In this case I just want to leave that row unchanged.

UPDATE tab_a
SET col_1 = 'NEWVALUE'
WHERE EXISTS (SELECT 1

                                FROM tab_a a, tab_b b
                                WHERE a.col_2 = b.col_2)
                                AND col_1 IS NULL;

Any ideas to what I'm doing wrong?

-- 

Cheers,

elziko
Received on Wed May 26 2004 - 04:51:32 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US