-3

我怎样才能从两个限制为 4 的表中从 mysql ORDER BY date 中取出?我想从两个表 ORDER BY date >= DATE(NOW()) 中得到一个混合。

tbl1 
id      place1    date1  
1   |  example | 2013-01-05
2   |  example | 2013-07-05
3   |  example | 2013-23-05

tbl2
id      place2    date2  
1   |  example | 2013-05-05
2   |  example | 2013-06-05
3   |  example | 2013-20-05
4

1 回答 1

3
SELECT *
FROM (SELECT id, place1 place, date1 date
        FROM tbl1
       WHERE date1 > CURDATE()
      UNION
      SELECT id, place2 place, date2 date
        FROM tbl2
       WHERE date2 > CURDATE()) tbl12
ORDER BY date DESC
LIMIT 4
于 2013-04-30T12:13:25.770 回答