如何选择多个表(组合表:没有连接,因为所有字段都相同)?
我有2张桌子: +表A
id | name | description | time
1 A AA 7:01
2 B BB 7:03
+表B
id | name | description | time
1 C CC 7:02
2 D DD 7:04
我想结果:
结果:(按时间顺序)
id | name | description | time
1 A AA 7:01
1 C CC 7:02
2 B BB 7:03
2 D DD 7:04
答案 0 :(得分:1)
使用Union all
select id, name, description, time from tableA
Union all
select id, name, description, time from tableB
order by time
答案 1 :(得分:1)
您可以使用UNION ALL
select *
from (
select * from TableA
union all
select * from TableB
) t1
order by time
如果您有重复项并希望避免重复,只需从UNION ALL
切换到UNION