--1select top 10 公共字段 from t1 order by pubdate --desc 排序方式 union --all 可以取重复 select top 10 公共字段 from t1 order by pubdate --desc union --all ...--2 select top 10 * from( select 公共字段 from t1 union --all 可以取重复 select 公共字段 from t1 union --all ... ) t order by pubdate --desc
select top 10 * from (select * from t1 union all select * from t2 union all select * from t3 select * from t4 union all select * from t5 union all select * from t6)t order by pubdate desc
select top 10* from t1 order by pubdate desc union all select top 10* from t2 order by pubdate desc ... select top 10* from t6 order by pubdate desc
select top 10 * from ( select * from T1 union all select * from T2 union all select * from T3 union all select * from T4 union all select * from T5 union all select * from T6 ) a order by [日期] desc
不懂lz的意思,什么是视图?View?
select top 10 * from T1 union all select * from T2 union all select * from T3 union all select * from T4 union all select * from T5 union all select * from T6 order by pubdate
表数据多试试这样子。 select top 10 * from( select top 10 公共字段 from t1 order by pubdate --desc union select top 10 公共字段 from t2 order by pubdate --desc union ... ) t order by pubdate --desc
lz是来搞笑的,看下view的概念
做了个测试: declare @t table(pubdate datetime)--包括其他列 insert into @t select top 10 pubdate from t1 order by pubdate desc insert into @t select top 10 pubdate from t2 order by pubdate desc insert into @t select top 10 pubdate from t3 order by pubdate desc insert into @t select top 10 pubdate from t4 order by pubdate desc insert into @t select top 10 pubdate from t5 order by pubdate desc insert into @t select top 10 pubdate from t6 order by pubdate desc select top 10 * from @t order by pubdate desc --上述查询,总开销62,下句开销38% select top 10 * from( select top 10 pubdate from t1 order by pubdate desc union all select top 10 pubdate from t2 order by pubdate desc union all select top 10 pubdate from t3 order by pubdate desc union all select top 10 pubdate from t4 order by pubdate desc union all select top 10 pubdate from t5 order by pubdate desc union all select top 10 pubdate from t6 order by pubdate desc )t order by pubdate
一般就这样了, select top 10* from t1 order by pubdate desc union all select top 10* from t2 order by pubdate desc ... select top 10* from t6 order by pubdate desc
--1select top 10 公共字段 from t1 order by pubdate --desc 排序方式
union --all 可以取重复
select top 10 公共字段 from t1 order by pubdate --desc
union --all
...--2
select top 10 *
from(
select 公共字段 from t1
union --all 可以取重复
select 公共字段 from t1
union --all
...
) t
order by pubdate --desc
union all
select top 10* from t2 order by pubdate desc
...
select top 10* from t6 order by pubdate desc
select top 10 * from (
select * from T1
union all
select * from T2
union all
select * from T3
union all
select * from T4
union all
select * from T5
union all
select * from T6
) a order by [日期] desc
select top 10 * from T1
union all
select * from T2
union all
select * from T3
union all
select * from T4
union all
select * from T5
union all
select * from T6
order by pubdate
select top 10 *
from(
select top 10 公共字段 from t1 order by pubdate --desc
union
select top 10 公共字段 from t2 order by pubdate --desc
union
...
) t
order by pubdate --desc
declare @t table(pubdate datetime)--包括其他列
insert into @t select top 10 pubdate from t1 order by pubdate desc
insert into @t select top 10 pubdate from t2 order by pubdate desc
insert into @t select top 10 pubdate from t3 order by pubdate desc
insert into @t select top 10 pubdate from t4 order by pubdate desc
insert into @t select top 10 pubdate from t5 order by pubdate desc
insert into @t select top 10 pubdate from t6 order by pubdate desc
select top 10 * from @t order by pubdate desc
--上述查询,总开销62,下句开销38%
select top 10 * from(
select top 10 pubdate from t1 order by pubdate desc
union all
select top 10 pubdate from t2 order by pubdate desc
union all
select top 10 pubdate from t3 order by pubdate desc
union all
select top 10 pubdate from t4 order by pubdate desc
union all
select top 10 pubdate from t5 order by pubdate desc
union all
select top 10 pubdate from t6 order by pubdate desc
)t order by pubdate
select top 10* from t1 order by pubdate desc
union all
select top 10* from t2 order by pubdate desc
...
select top 10* from t6 order by pubdate desc