Append two values in different tables

Database

Append two values in different tables

 Hi All,

 

Can some one help me with this logic

 

Table A                                                                               

empID  EmailId                 Product                       

1234     aaa@gmail.com   A,B,C                          

 

Table B

EmpID   EmailID             Product

1234     aaa@gmail.com   C,D

 

Join above tables with empid and mailid and update TableA like below

 

 

Table A

empID  EmailId                 Product

1234     aaa@gmail.com   A,B,C,D

 

the values in product should be unique.

 

 

 

Tags (2)

Accepted Solutions
Junior Contributor

Re: Append two values in different tables

UNION ALL both tables, normalize your data using STRTOK_SPLIT_TO_TABLE, apply DISTINCT and denormalize again using RANK/CASE or XMLAGG.

 

But better fix your data model.

1 ACCEPTED SOLUTION
1 REPLY
Junior Contributor

Re: Append two values in different tables

UNION ALL both tables, normalize your data using STRTOK_SPLIT_TO_TABLE, apply DISTINCT and denormalize again using RANK/CASE or XMLAGG.

 

But better fix your data model.