select a.*,b.* from Topic a INNER JOIN (select * from Post t where not exists(select 1 from Post where TopicID = t.TopicID and PostTime > t.PostTime)) b on a.TopicID = b.TopicID
select a.* from topic a , (select top 1 topicID from post order by posttime desc ) b where a.topicID =b.topicID这样好像是比较慢的...
select a.* ,b.* from a inner join b on a.id=b.id order by 时间 desc
TopicID | title | createtimePost表
PostID | Author | postTime | TopicID
INNER JOIN
(select * from Post t
where not exists(select 1 from Post where TopicID = t.TopicID and PostTime > t.PostTime)) b
on a.TopicID = b.TopicID
from topic a , (select top 1 topicID from post order by posttime desc ) b
where a.topicID =b.topicID这样好像是比较慢的...
order by 时间 desc