问题
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 #2
Table Final
Default value of Qty column is "0" and users will change it at run-time.
I've created Table#1 and Table#2 and they work fine.
I just don't know how can I add rows of Table#1 and Table#2 where "Qty" is bigger than "0" into Table Final.

Note: id column of each tables is PRIMARY KEY AUTOINCREMENT
回答1:
INSERT INTO "Table Final"(Product, Qty)
SELECT Product, Qty FROM "Table #1" WHERE Qty > 0
UNION ALL
SELECT Product, Qty FROM "Table #2" WHERE Qty > 0;
回答2:
You could use union
wordkey to achieve this.
INSERT INTO Final(Product, Qty)
(SELECT Product, Qty FROM t1 where Qty > 0)
UNION ALL
(SELECT Product, Qty FROM t2 where Qty > 0)
Hope it helps
来源:https://stackoverflow.com/questions/25947396/fetch-data-of-two-tables-and-insert-to-new-table