Reputation: 457
I'm trying to get a result from two sqlite tables that contain the same columns but have no other relation. Both have the date
and amount
columns and all I want is a new table as a result to show dates and amounts from both tables.
Table A
+----------+-------+
| date | amount|
+----------+-------+
|10-01-2013| 3.8 |
|12-23-2104| 4.2 |
+----------+-------+
and
Table B
+----------+-------+
| date | amount|
+----------+-------+
|10-03-2013| 2.4 |
|12-28-2014| 3.5 |
+----------+-------+
And the desired table would be
+----------+----------+---------+
| date | A.amount | B.amount|
+----------+----------+---------+
|10-01-2013| 3.8 | NULL |
|10-03-2013| NULL | 2.4 |
|12-23-2104| 4.2 | NULL |
|12-28-2014| NULL | 3.5 |
+----------+----------+---------+
I tried many posts in the forum but I couldn't find any that match my need.
Could you help?
Upvotes: 0
Views: 115
Reputation: 85
What you need is not a JOIN is a UNION.
see:
Something like:
SELECT Date, Amount as Amount1, NULL AS Amount2
FROM TableA
UNION ALL
SELECT Date, NULL AS Amount1, Amount as Amount2
FROM TableB
Upvotes: 2