select
a.id,
a.name,
a.taskname,
a.detail,
b.status,
b.time
from
表a a,
表b b
where
a.id=b.id and not exists(select 1 from 表b where id=b.id and sid>b.sid)
a.id,
a.name,
a.taskname,
a.detail,
b.status,
b.time
from
表a a,
表b b
where
a.id=b.id and not exists(select 1 from 表b where id=b.id and sid>b.sid)
a.id,a.name,taskname,detail,status
a.id,a.name,b.taskname,b.detail,b.status
id name taskname detail status time
1 n1 t1 d1 s3 t4
1 n1 t1 d1 s2 t1
3 n3 t3 d3 s2 t3
Select B.id,B.status,B.time From B inner join
(Select id,max(time) time From B Group By id) C
on B.time=C.time) T on A.id=T.id