这个select语句怎么写?

现在很多论坛都在标题后面加上了一个最后回复人和最后回复时间,请问这个是怎么实现的!

我看了一些源码,它们是在存储论坛的贴子的forum里加了两个列用来存取‘回复人、回复时间’!如果不这样考虑,有没有办法通过一个select语句将它们选择出来!
---------------------------------------------------------------

select 回复人,回复时间 from tablename where id = '???' and 回复时间 = (select max(回复时间) from tablename where id = '???')
---------------------------------------------------------------

select *
from tablename a
where time=(select max(time) from tablename where id=a.id)
and ...
---------------------------------------------------------------

select a.id,title,addname,plint,re,b.time_max
from board a,
(select id,time_max=max(time)
from 回复记录明细表
group by id) as b
where a.id = b.id

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus