Find duplicate values in one column:
SELECT 
    email, 
    COUNT(email) AS cnt
FROM
    contacts
GROUP BY email
HAVING cnt > 1;
Find duplicate values in multiple columns:
SELECT 
    first_name, COUNT(first_name) as cnt_fn,
    last_name,  COUNT(last_name)  as cnt_ln,
    email,      COUNT(email)  as cnt_m
FROM
    users
GROUP BY 
    first_name , 
    last_name , 
    email
HAVING  cnt_fn > 1
    AND cnt_ln > 1
    AND cnt_m > 1;
by Luka Tatarishvili
4 years ago
MySQL
Select
1
Pro tip: use ```triple backticks around text``` to write in code fences
2
გიორგი უზნაძე 4 years ago
kai methodia, btw tu marto duplicatebis washla gwirdeba amis gamoyeneba shegidzlia
DELETE t1 FROM table_name t1
INNER JOIN table_name t2 
WHERE 
    t1.id < t2.id AND 
    t1.email = t2.email;
REPLY
Show 1 reply
1
Valeri Tandilashvili 4 years ago
ორჯერ რომ არ ათვლევინო, ასე არ ჯობია ?
SELECT 
    email, 
    COUNT(email) AS cnt
FROM
    contacts
GROUP BY email
HAVING cnt > 1;
REPLY