试试:
--子帖的最大时间sql:
select t1.fld_pid,max(t1.fld_createtime) as max_time
from tbl t1, tbl t2
where t1.fld_pid in (select distinct t2.fld_id from tbl t2)
group by t1.fld_pid--楼主需要的sql:
select a.fld_id, fld_body
from tbl a, (select t1.fld_pid,max(t1.fld_createtime) as max_time
from tbl t1, tbl t2
where t1.fld_pid in (select distinct t2.fld_id from tbl t2)
group by t1.fld_pid) b
where a.fld_pid = 0 --父
and a.fld_id = b.fld_pid
order by b.max_time desc
--子帖的最大时间sql:
select t1.fld_pid,max(t1.fld_createtime) as max_time
from tbl t1, tbl t2
where t1.fld_pid in (select distinct t2.fld_id from tbl t2)
group by t1.fld_pid--楼主需要的sql:
select a.fld_id, fld_body
from tbl a, (select t1.fld_pid,max(t1.fld_createtime) as max_time
from tbl t1, tbl t2
where t1.fld_pid in (select distinct t2.fld_id from tbl t2)
group by t1.fld_pid) b
where a.fld_pid = 0 --父
and a.fld_id = b.fld_pid
order by b.max_time desc
select a.fld_id, fld_body
----->
select a.fld_id, a.fld_body