fbpx

Finding duplicate records in mysql

Finding duplicate records in mysql

We have two tables epaper and epaper_pages. Every epaper_pages table recrod has a specific page number assigned. We have to check that each epaper_pages table record  has no epaper_page_no duplicate number.

SELECT
	(
		SELECT
			COUNT(*)
		FROM
			epaper_pages
		WHERE
			epaper_pages.epaper_id = epaper.id
		GROUP BY
			epaper_pages.epaper_page_no
		HAVING
			COUNT(*) > 1
	) AS dublicate_count,
	epaper.*
FROM
	epaper
ORDER BY
	dublicate_count DESC

 

Share this post