MySQL 查询重复数据

MySQL 面试 About 299 words

SQL

  • 查询哪些字段,重复了多少次
SELECT name , COUNT(name) from user2 GROUP BY `name` 
  • 查询哪些字段,重复了2次以上
SELECT name , COUNT(name) from user2 GROUP BY `name` HAVING COUNT(`name`) > 1
  • 查询分别是哪几条记录重复了2次以上
SELECT * from user2 WHERE `name` in (
SELECT name from user2 GROUP BY `name` HAVING COUNT(`name`) > 1
)
Views: 2,237 · Posted: 2019-04-07

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh