日期:2014-05-18 浏览次数:20635 次
select * from 表A a,表B b where a.id=b.infoid and not exists(select 1 from 表B where infoid=b.infoid and comid>a.comid)
------解决方案--------------------
select * from 表A a,表B b where a.id=b.infoid and not exists(select 1 from 表B where infoid=b.infoid and comid>b.comid)
------解决方案--------------------
select a.id,a.title,a.date,b.comid,b.detail,b.username from 表A a left join 表B b on a.id=b.infoid where not exists(select 1 from 表B where infoid=b.infoid and comid>b.comid)
------解决方案--------------------
select a.id,a.title,a.date,b.comid,b.detail,b.username from 表a a join 表b b on a.id=b.infoid where a.date=(select max(date) from 表a where id=a.id)