1

I need show duplicates mobile in database.

i have base like: id_client, name, surname, adress, mobile, email etc. etc....

and i try query:

SELECT mobile, COUNT(mobile) 
FROM clients
GROUP BY mobile
HAVING COUNT(mobile)>1;

Its shows me duplicate mobiles and how many (count) its double.

I need last column to list duplicate id_clients like:

ect:

mobile,        count(mobile),    list_id_duplicate_clients
+48510509490 |  7             |   135,124,821,212,532,234, 
+48555555555 |  15            |   11, 14 

(...)

How i can make last (three) column? plx help


edit: Ok i have code:

select
 nip,
 GROUP_CONCAT(id_client ORDER BY nip SEPARATOR ', ') as double_nip
FROM clients
GROUP BY nip having COUNT(*) > 1

its make me NIP duplicate

and

select
 mobile,
 GROUP_CONCAT(id_client ORDER BY mobile SEPARATOR ', ') as double_mobile
FROM clients
GROUP BY mobile having COUNT(*) > 1

Its make me MOBILE duplicate

But how i can compare NIP and MOBILE and show:

mobile,         nip_duplicate,      mobile_duplicate
+48510509490 |     135,124,821   |   111,155,12
+48555555555 |   11, 14          |   121, 241 

sb can help?

  • 1
    Possible duplicate of [SQL Server : find duplicates in a table based on values in a single column](http://stackoverflow.com/questions/16525064/sql-server-find-duplicates-in-a-table-based-on-values-in-a-single-column) – Eray Balkanli Apr 20 '16 at 15:27
  • its duplicates in ms sql, not mysql – Dariusz Rup Apr 21 '16 at 08:29

0 Answers0