MySQL 查询表中某字段值重复的数据
MySQL中,查询表(dat_bill_2018_11)中字段(product_id)值重复的记录:
SELECT product_id, COUNT(*) AS sumCount FROM dat_bill_201811 GROUP BY product_id HAVING sumCount > 1;
说明:先用GROUP BY 对 product_id 进行分组,同时使用COUNT(*)进行统计,再用HAVING来过滤大于1的,这样查找出来的就是重复的记录了。
Good Good Study, Day Day Up.
顺序 选择 循环 总结