SQL多表连接查询时间最新的

select * from table1 as a
left join table2 as b on a.ID = b.ID
where exists
(
select table1 from
(
select ID ,max(DateTime) as Time
from table1 group by ID
)as n where n.ID= b.ID and n.Time= a.DateTime
)

posted @ 2015-09-14 16:42  新城已无在少年  阅读(460)  评论(0编辑  收藏  举报