我有两个不同的表,每个表都有一个同名的列(is_featured)。我正在尝试从这两个相同的“is_featured”列中选择并显示 item_name,并按日期 desc 排序。
视频
item_name | is_featured | date | item_active
item a | yes | 1-1-13 | 1
item b | no | 1-13-13 | 1
item c | yes | 1-3-13 | 1
相片
item_name | is_featured | date | item_active
item d | no | 2-1-13 | 1
item e | no | 1-2-13 | 1
item f | yes | 1-19-13 | 1
我尝试对这两个表使用 UNION 查询,但我不知道如何按日期对组合结果进行排序。
(SELECT item_name FROM Videos WHERE item_active=1 ORDER BY date DESC)
UNION
(SELECT item_name FROM Photos WHERE item_active=1 ORDER BY date DESC)
我错过了什么?UNION 是不正确的方法吗?