View previous topic :: View next topic
|
Author |
Message |
rahuindo
New User
Joined: 09 Apr 2008 Posts: 83 Location: Chennai
|
|
|
|
I have the following requirements:
There are two tables UTT_EMPL_MGR and UTT_EMPL_ID.
The columns in the table UTT_EMPL_MGR are as follows:
EMPL_ID
MGR_EMPL_ID
REL_TYP_CD
REL_FINAL_CD
The columns in the table UTT_EMPL_MGR are as follows:
EMPL_NUM
MGR_EMPL_NUM
REL_TYP_CD
REL_FINAL_CD
The above two tables have the parent table as UTT_EMPL. The columns in the table UTT_EMPL are:
EMPL_ID
EMPL_NUM
EMPL_NAME
TERM_CD
For some Employees, the REL_FINAL_CD is not matching between the UTT_EMPL_MGR and UTT_EMPL_ID. If i have to update the REL_FINAL_CD
of all the erroneous records in the UTT_EMPL_ID with the REL_FINAL_CD of UTT_EMPL_MGR, then is there a way to write the Update query?
Thanks!! |
|
Back to top |
|
|
Prajesh_v_p
Active User
Joined: 24 May 2006 Posts: 133 Location: India
|
|
|
|
Please check whether something like below will work for you(I hope the key match MGR.MGR_EMPL_ID = ID.EMPL_NUM is correct) :
UPDATE UTT_EMPL_ID ID
SET ID.REL_FINAL_CD = (
SELECT MGR.REL_FINAL_CD
FROM UTT_EMPL_MGR MGR
WHERE MGR.MGR_EMPL_ID = ID.EMPL_NUM )
WHER ID.REL_FINAL_CD NOT IN(
SELECT MG1.REL_FINAL_CD
FROM UTT_EMPL_MGR MG1
WHERE MG1.MGR_EMPL_ID = ID.EMPL_NUM );
I am not sure whether we can get rid of these two subqueries! |
|
Back to top |
|
|
|