日期:2014-05-17 浏览次数:20550 次
SELECT * FROM A,B WHERE B.DATETIME=(SELECT MAX(DATETIME) WHERE A.AID=B.BID) AND A.AID=B.BID
SELECT * FROM A left join
(select * from B t where not exists(select 1 from B where BID=t.BID and [DATETIME
]>t.DATETIME
)) n
on A.AID=n.BID
select m.* , n.*
from a m left join b n
on m.AID = n.BID and n.DATETIME = (select max(DATETIME) from b where bid = n.bid)
select m.* , n.*
from a m left join b n
on m.AID = n.BID and not exists (select 1 from b where bid = n.bid and DATETIME > n.DATETIME)