用select * from users t where not exists (select 1 from users where userid=t.userid and id >t. id) (id为编号,或者可以用其他的只要是数据库中不重复的字段就成),同时还达到了一个效果,第一次入库的userid才被计算 在内,这在许多情况下还是比较有用的(比如处理误操作什么的)。
转载于:https://my.oschina.net/u/254813/blog/173223