smyh 发表于 2008-9-4 10:55

回复最新查询

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

这里没有回复的不能显示,谁能帮我改一下啊!

happynight 发表于 2008-9-4 11:01

看的不是很明白
拿几条数据作范例说明下

smyh 发表于 2008-9-4 11:18

就是把最新回复的显示在最前面,而没有回复的显示在后面

[attach]36914[/attach]

西风独自凉 发表于 2008-9-4 15:23

select * from  a  order by 回復時間﹐回復內容  desc
這樣好像就可以

[[it] 本帖最后由 西风独自凉 于 2008-9-4 15:31 编辑 [/it]]

smyh 发表于 2008-9-6 13:54

好象不行,不过还是谢谢楼上

acupoflife 发表于 2008-9-8 15:02

4楼的排序应该对啊。。按照回复时间最新排列

页: [1]

编程论坛