Skip to content Skip to sidebar Skip to footer

Fetch Data Of Two Tables And Insert To New Table

I have three activities in my application with following names: Activity #1 Activity #2 Activity Final Also for each activity, I have a table with following names: Table #1 Table #

Solution 1:

INSERTINTO "Table Final"(Product, Qty)
SELECT Product, Qty FROM "Table #1" WHERE Qty >0UNIONALLSELECT Product, Qty FROM "Table #2" WHERE Qty >0;

Solution 2:

You could use unionwordkey to achieve this.

INSERTINTOFinal(Product, Qty)
(SELECT Product, Qty FROM t1 where Qty >0)
UNIONALL
(SELECT Product, Qty FROM t2 where Qty >0)

Hope it helps

Post a Comment for "Fetch Data Of Two Tables And Insert To New Table"