11,847
社区成员
发帖
与我相关
我的任务
分享
uid uname sex age
1 admin 男 25
2 sky 女 18
3 sref 男 32
5 ndsb 男 24
id uid result date
1 2 10 2010-02-03 00:00:00.000
2 2 12 2011-02-03 00:00:00.000
3 2 14 2010-02-04 00:00:00.000
4 3 34 2010-02-04 00:00:00.000
5 3 32 2011-02-04 00:00:00.000
6 3 33 2011-02-04 00:00:00.000
uid uname sex result age date
1 admin 男 NULL 25 NULL
2 sky 女 12 18 2011-02-03 00:00:00.000
3 sref 男 32 32 2011-02-04 00:00:00.000
5 ndsb 男 NULL 24 NULL
select a.uid,a.uname,a.sex,t.result,a.age,t.date
from a left join(
select * from b d where not exists
(select 1 from b where uid=d.uid and (date>d.date or date=d.date and id>d.id))
)t on a.uid=t.uid