Daniel Yeffet Daniel Yeffet - 1 year ago 40
SQL Question

Find identical IP from database and combine it to one result

I have a table named "ips" that contains all of my users IPs.
I want to find duplicated accounts and report it for me.
I want to see all users that have the same IP, for example:
"a" has the same ip as "b", and "c" has the same ip as "d".
So I want to get a query that gets me-

User 1: "a", User 2: "b", ip:
User 1: "c", User 2: "d", ip:

What's the best query to do so? (PHP/Mysql)


How about

select ip, group_concat(user_name) as users
from ips
group by ip
having count(*) > 1