天天看點

MySQL 查詢重複記錄

版權聲明:本文首發 http://asing1elife.com ,轉載請注明出處。 https://blog.csdn.net/asing1elife/article/details/82892848

資料庫中如果插入重複記錄,需要有效排查出重複結果

更多精彩

方法

SELECT 
	* 
FROM 
	pt_university_institute_staff
WHERE 
	staffId IN (
		SELECT 
			co.staffId 
		FROM (
			SELECT 
				staffId, count(*) AS count 
			FROM 
				pt_university_institute_staff 
			GROUP BY 
				staffId 
			HAVING 
				count > 1
		) co
	);
                
上一篇: MySQL 指令