同时查询几个表SQL
小弟想同时查询12个表每个显示的字段都不相同,最后要按照时间显示20条记录.请问这样的SQL怎么写!
小弟在这里谢谢了!!
[解决办法]
select col1, col2 from tb1
union all
select col1, col2 from tb2
union all
...
[解决办法]
select top 20 * from (select time,a,b from t1 union all select time,c,d from t2...) t order by time
[解决办法]
用union
[解决办法]
表结构相同的话用UNION ALL不同的话补上空字段.