删除表中多余的重复记录,重复记录是根据单个字段peopleName来判断,只留有peopleId最小的记录:
123delete from peoplewhere peopleName in (select peopleName from people group by peopleName having count(peopleName) > 1)and peopleId not i...
阅读全文…
distinct用法在使用MySQL时,有时需要查出某个字段不重复的字段,这时可以使用MySQL提供的distinct关键字来过滤重复的记录,但是实际中往往使用distinct来返回不重复字段的条数(count(distinct id)),其原因是distinct只能返回它的目标字段,而无法返回其他字段,其常见用法为:
1select distinct name from user;
这样可...
阅读全文…