注册 登录
编程论坛 SQL Server论坛

回复最新查询

smyh 发布于 2008-09-04 10:55, 1059 次点击
create table article(
 aid int identity(1,1) primary key,
 sid int not null,--类别ID
 atitle varchar(100) not null,--文章标题
 acontent text not null,--文章内容
 mid int not null,--发布人ID
 adate datetime not null,--发布时间
 anum int not null,--浏览量
)
select a.* from article a join (select pid,adate=max(adate) from article where pid<>0 group by pid) b on (a.aid=b.pid) order by b.adate desc

这里没有回复的不能显示,谁能帮我改一下啊!
5 回复
#2
happynight2008-09-04 11:01
看的不是很明白
拿几条数据作范例说明下
#3
smyh2008-09-04 11:18
就是把最新回复的显示在最前面,而没有回复的显示在后面

只有本站会员才能查看附件,请 登录
#4
西风独自凉2008-09-04 15:23
select * from  a  order by 回復時間﹐回復內容  desc
這樣好像就可以

[[it] 本帖最后由 西风独自凉 于 2008-9-4 15:31 编辑 [/it]]
#5
smyh2008-09-06 13:54
好象不行,不过还是谢谢楼上
#6
acupoflife2008-09-08 15:02
4楼的排序应该对啊。。按照回复时间最新排列
1