Reputation: 21
I have two tables with the same columns and I want to make a union between them, in such a way that I get a table in which I only have the products_id that match between them.
Simplifying my case and omitting the rest of the columns (customer_id, order_date_id, etc.):
TABLE 1:
product_id
1
2
2
2
TABLE 2:
product_id
1
1
3
4
The result I want to achieve in this case would be the following:
TOTAL TABLE:
product_id
1
1
1
2
2
2
PS: Note that there are more columns, so the UNION() function by itself is not enough.
Thanks a lot!!
Upvotes: 0
Views: 331
Reputation: 2615
Please test this if I understand correctly:
CombinationTable =
VAR Tbl_1 = Table1
VAR Tbl_2 =
INTERSECT ( Table2, Table1 )
VAR Combination =
UNION ( Tbl_1, Tbl_2 )
RETURN
Combination
Upvotes: 1