Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addr_id emp_id emp_name email1 isprimary
- --------- ------ -------- ----------------- ----------
- 201 101 John John@gmail.com 1
- 202 101 John John_1@gmail.com 0
- 203 101 John John_2@gmail.com 0
- 205 104 Bond Bond@gmail.com 1
- 206 104 Bond Bond_4@gmail.com 0
- 207 104 Bond Bond_5@gmail.com 0
- update x_addr_table1
- set email1=(select P1.priemail1
- from x_primary_email_table2 P1, x_profilepay_email_table3 P2
- where P1.emp_id=P2.emp_id )
- from x_addr_table1 a
- inner join x_primary_email_table2 T1
- on a.address_id=T1.address_id
- where a.emp_id=T1.emp_id
- MERGE x_addr_table1 A
- USING (select T2.addr_id,T2.email1,T2.emp_id from x_primary_email_table2 T2, x_profilepay_email_table3 T3 where T2.emp_id=T3.emp_id and upper(T2.email1)!=upper(T3.email1)) as Source
- ON (a.addr_id=Source.addr_id and a.emp_id=source.emp_id)
- WHEN MATCHED THEN
- UPDATE SET a.email1=Source.email1
- update x_addr_table1 a
- set email1=
- (
- select T2.priemail1
- from x_primary_email_table2 T2
- where T2.emp_id=a.emp_id
- )
- where a.addr_id in
- (
- select T2.addr_id
- from x_primary_email_table2 T2
- )
- and a.emp_id in
- (
- select T2.emp_id
- from x_primary_email_table2 T2, x_profilepay_email_table3 T3
- where t2.emp_id=t3.emp_id
- and upper(T2.priemail1)!=upper(T3.payemail1)
- )
Add Comment
Please, Sign In to add comment