I have 2 tables with similar, but different data. Both tables have an insert timestamp column of their own.
Table A Table B
+------------+----------+ +------------+----------+
| a_created | a_data | | b_created | b_data |
+------------+----------+ +------------+----------+
| 2012-09-01 | A | | 2012-09-03 | C |
| 2012-09-05 | B | | 2012-09-04 | D |
+------------+----------+ +------------+----------+
I’d like to get all the data from these tables, sorted via a merged date column by the two creation dates. I.e. I want the following results
+------------+----------+----------+
| x_created | a_data | b_data |
+------------+----------+----------+
| 2012-09-01 | A | NULL |
| 2012-09-03 | NULL | C |
| 2012-09-04 | NULL | D |
| 2012-09-05 | B | NULL |
+------------+----------+----------+
Is this even possible without altering the schema? If so, how?
Building on mrmryb’s answer by adding the sort you asked for and using true NULLs: