home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.oracle      Overblown overpriced overengineered SHIT      2,288 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,441 of 2,288   
   elziko to All   
   Update rows when in other table   
   26 May 04 10:51:32   
   
   From: elziko@NOTSPAMMINGyahoo.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   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca