我正在尝试按日期从两个表顺序中获取数据:
JFrog XRay HA(Add-on option)
这将按日期从新闻顺序中返回3个项目,然后按日期从文章顺序中返回3个项目:
(SELECT * FROM news ORDER BY date DESC LIMIT 3)
UNION
(SELECT * FROM article ORDER BY date DESC LIMIT 3);
但是我想按日期组合数据顺序,如下所示:
- news 1 (2018-8-22)
- news 2 (2018-7-19)
- news 3 (2018-6-13)
- article 1 (2018-8-22)
- article 2 (2018-7-18)
- article 3 (2018-6-12)
有什么想法吗?
答案 0 :(得分:0)
添加外部选择:
select * from
(SELECT * FROM news LIMIT 3
UNION
SELECT * FROM article LIMIT 3) as x
ORDER BY date DESC