sql语句排除重复

用select * from users t where not exists (select 1 from users where  userid=t.userid and id >t. id)  (id为编号,或者能够用其余的只要是数据库中不重复的字段就成),同时还达到了一个效果,第一次入库的userid才被计算 在内,这在许多状况下仍是比较有用的(好比处理误操做什么的)。
相关文章
相关标签/搜索