读书人

多表查询的有关问题

发布时间: 2012-02-12 17:16:33 作者: rapoo

多表查询的问题
如有2个表,分别记录08年和09年的数据,我想找08年某时间到09年某时间的数据并排序,用UNION连接2个SELECT是可以,但不能排序,有什么办法能解决吗?不能破坏原表结构,最好不要有临时的表

[解决办法]
select * from (
select * from t2008 where xx=ccc
union all
select * from t2008 where xx=ccc
) t
order by id ;

读书人网 >SQL Server

热点推荐