我会假设一些东西union
就足够了,因为没有上下文我只能假设这是你正在寻找的东西?
SELECT t.id, t.date_in AS alias FROM test t UNION ALL SELECT t2.id, t2.date_out AS alias FROM test t2 ORDER BY alias ASC;
会给你一个如下结果:
+----+---------------------+ | id | alias | +----+---------------------+ | 2 | 2016-01-01 12:00:00 | | 1 | 2016-01-01 12:00:00 | | 2 | 2016-01-02 12:00:00 | | 1 | 2016-01-03 12:00:00 | +----+---------------------+ 4 rows in set (0.00 sec)