A左关联B,取从B表多条记录取一条 select * from a left join b on a.ID = b.IDwhere not exists (select 1 from b t where t.ID = b.ID and t.TimeEnd > b.TimeEnd)