tags:

views:

22

answers:

1

My query:

UPDATE I_USER   
   SET END_DATE = (select ENDDAT
                    FROM TEMP_USER
                   WHERE USERNAME = 'ABC')  
 where USER_NAME = 'ABC';

This is the code for updating one row with where condition.If i want to update all the records in I_USER with the ENDDATE as per the TEMP_USER ,WHAT SHOULD I DO..?

+3  A: 

Use:

UPDATE I_USER   
   SET END_DATE = (SELECT tu.enddat
                     FROM TEMP_USER tu
                    WHERE tu.username = I_USER.username)  
 WHERE EXISTS(SELECT NULL
                FROM TEMP_USER t
               WHERE t.username = I_USER.username)
OMG Ponies