Mysql查詢重復記錄


第一步 使用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`


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM