求教高效率的分类新闻同时显示的查询
分类表
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