读书人

SQL 两个结果集拼接起来的有关问题

发布时间: 2012-03-17 19:06:28 作者: rapoo

SQL 两个结果集拼接起来的问题

SQL code
select Sid,count(*)as Num from t_forums a group by Sidselect b.*,c.SectionName from t_forums b,t_sections cwhere b.Id=(select max(id)as Id from t_forums where Sid=c.Id)


接不起来,求高手指导指导

sid num
17
18
20

sid ... SectionName
17
18
20


[解决办法]
SQL code
select a.*,       b.*,       c.SectionName from t_forums b,t_sections c,(select Sid,       count(*)as Num from t_forums a group by Sid)awhere b.Id=(select max(id)as Id from t_forums where Sid=c.Id)and a.sid=b.sid 

读书人网 >SQL Server

热点推荐