select non duplicate rows in mysql code example
Example 1: select where duplicate mysql
SELECT
col1, COUNT(col1),
col2, COUNT(col2)
FROM
table_name
GROUP BY
col1,
col2
HAVING
(COUNT(col1) > 1) AND
(COUNT(col2) > 1);
Example 2: mysql delete duplicate rows except one
DELETE FROM NAMES
WHERE id NOT IN (SELECT *
FROM (SELECT MIN(n.id)
FROM NAMES n
GROUP BY n.name) x)