求教高效率的分类新闻同时显示的查询
分类表
A
B
C
D
....
新闻表
xxx
xxxx
xx
......
页面显示
A类
xxxx
xxxx
B类
xxxx
xxxx
C类
xxxx
xxxx
....如次一个分类,N条记录,有没有办法用一调SQL查询来实现这样的数据要求,现在用的方法,每个分类都要查一次新闻表,实在太痛苦了,求高手解决
[最优解释]
查新闻表的时候, left outer join 分类表,然后在程序中分类显示
[其他解释]
有没有办法用一调SQL查询来实现这样的数据要求
-->一个SQL语句只能查询出一个结果集。你想要几个结果集给你?
[其他解释]
create procedure usp_test
as
begin
select * into #temp from 分类表
-----------
select * from 新闻表 inner join #temp...
where type='A'
select * from 新闻表 inner join #temp...
where type='B'
select * from 新闻表 inner join #temp...
where type='C'
end
[其他解释]
建议进行表中字段冗余
新闻表 根据分类的字段进行合并 进行统计
select * from 新闻表 where 分类=A
union all
select * from 新闻表 where 分类=B
union all
select * from 新闻表 where 分类=C
[其他解释]
继续求教,高手来
[其他解释]
继续求教
[其他解释]
没高手。。。蛮失望的
不过谢谢楼上两位帮盯
[其他解释]
每天盯一下。。。。
高手都哪去了