Reputation: 17
How to select multiple table (combine table: no join, because all field are the same)?
I have 2 tables: +Table A
id | name | description | time
1 A AA 7:01
2 B BB 7:03
+Table B
id | name | description | time
1 C CC 7:02
2 D DD 7:04
I want to result:
Result: (ORDER BY time)
id | name | description | time
1 A AA 7:01
1 C CC 7:02
2 B BB 7:03
2 D DD 7:04
Upvotes: 0
Views: 52
Reputation: 5916
You can use UNION ALL
select *
from (
select * from TableA
union all
select * from TableB
) t1
order by time
If you can have duplicates and want to avoid them, just switch from UNION ALL
to UNION
Upvotes: 1
Reputation: 69440
use Union all
select id, name, description, time from tableA
Union all
select id, name, description, time from tableB
order by time
Upvotes: 1