select v.* from vacate v where v.id not in (
select v1.id from vacate v1
INNER JOIN vacate v2 on v1.userId=v2.userId where v1.id<v2.id and v2.userId=2
) and v.userId=2
之前出错因为 没有 在里面添加==2条件,在外面也要加上才行
原文:https://www.cnblogs.com/genestart/p/11225020.html