select 1 from table where hideid=a.hideid and showid>a.showid ? 看不懂。你是不是指select a.*,b.* from table1 a,table2 b where not exists(select * from table2 where hideid=a.hideid and showid>a.showid) and a.fk=b.pk 这样也不行。
select a.*,b.* from table1 a,table2 b, (select hideid,max(showid) as maxshowid from table1 group by hideid) c where a.fk=b.pk and a.hideid = c.hideid and a.showid = c.maxshowid order by a.id
或者 select a.*,b.* from table1 a,table2 b where not exists(select 1 from table1 where hideid= a.hideid and showid>a.showid) and a.fk=b.pk
where not exists(select * from table2 where hideid=a.hideid and showid>a.showid)
and a.fk=b.pk
这样也不行。
(select hideid,max(showid) as maxshowid from table1 group by hideid) c
where a.fk=b.pk and a.hideid = c.hideid and a.showid = c.maxshowid
order by a.id
select a.*,b.* from table1 a,table2 b
where not exists(select 1 from table1 where hideid= a.hideid and showid>a.showid) and a.fk=b.pk