posted 15 years ago
Hi Friends,
I've a table ORG_TABLE has columns CU_ID,ACC_ID,PORT_ID,SUPPORT_ID,REAS_NAME. I also have a table TEMP_TABLE having columns CU_ID,ACC_ID,PORT_ID,SUPPORT_ID. ORG_TABLE got about 45000 records and TEMP_TABLE has about 10000 records.
While all the columns for a row in TEMP_TABLE are not filled all the time.For example for one row CU_ID and PORT_ID having values.For another row CU_ID and SUPPORT_ID having values.It may also be like ACC_ID and PORT_ID having values and rest are null.So such combinations will exist in TEMP_TABLE.
I'm looking for single query which would be some thing like(considering first row values from TEMp_TABLE) UPDATE ORG_TABLE set ORG_TABLE.REAS_NAME=TEMP_TABLE.REAS_NAME where ORG_TABLE.CU_ID=TEMP_TABLE.CU_ID and ORG_TABLE.PORT_ID=TEMP_TABLE.PORT_ID.Similary the update should execute for the second combinations and so on for all the records in TEMP_TABLE.Dynamically query should be formed.
Thanks in advance