数据库:MSSQL SERVER 2000
SQL如下:
declare @a int
declare @b int
declare @c int
set @a = 10 --(新闻的总数,为@b和@c之和)
set @b = 3 --(含图片的新闻条数)
set @c = 7 --(不含图片的新闻条数)declare @i int
set @i = @bset rowcount @i
select * from tb1 where imgflag = 1 ORDER BY …… /*第一次的查询结果*/
set rowcount 0set rowcount @a - @@rowcount
select * from tb1 where imgflag = 0 ORDER BY …… /*第二次的查询结果*/
set rowcount 0请问,如何将第一次和第二次的查询结果合并起来(实际项目比这个还复杂,所以不能用UNION和UNION ALL,一定要按此模式写),谢谢。
SQL如下:
declare @a int
declare @b int
declare @c int
set @a = 10 --(新闻的总数,为@b和@c之和)
set @b = 3 --(含图片的新闻条数)
set @c = 7 --(不含图片的新闻条数)declare @i int
set @i = @bset rowcount @i
select * from tb1 where imgflag = 1 ORDER BY …… /*第一次的查询结果*/
set rowcount 0set rowcount @a - @@rowcount
select * from tb1 where imgflag = 0 ORDER BY …… /*第二次的查询结果*/
set rowcount 0请问,如何将第一次和第二次的查询结果合并起来(实际项目比这个还复杂,所以不能用UNION和UNION ALL,一定要按此模式写),谢谢。
1、如果能把第一次和第二次的查询结果union起来,也是可以的。
2、不能使用临时表。