您的位置:首页 > 数据库 > MySQL

Mysql查询重复记录

2016-08-26 10:37 225 查看
第一步 使用group by 和 having cout 查找重复字段
SELECT t1.`order_book_id` FROM `quant_stock_info` t1 GROUP BY t1.`order_book_id` HAVING COUNT(t1.`order_book_id`)>1

第二步 使用IN查找

SELECT * FROM `quant_stock_info` t0
WHERE t0.`order_book_id`
IN (
SELECT t1.`order_book_id` FROM `quant_stock_info` t1
GROUP BY t1.`order_book_id` HAVING COUNT(t1.`order_book_id`)>1
)
ORDER BY t0.`order_book_id`
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: