Reputation:
I record IP addresses in my DB and i want to look at accounts that have the same IP address as eachother. I'd like to show only results with more then one IP addresses. I preferentially would like it sorted by IP addressed used the most (IE if i have 30accounts with 127.0.0.1 as my ip i rather have that higher then 10ip address that belong to 192.168.1.123).
How do i write this query? I am using mysql
Upvotes: 4
Views: 5247
Reputation: 617
SELECT ip, COUNT(*)
FROM Table
GROUP BY ip
HAVING COUNT(*) > 1
ORDER BY COUNT(*);
Upvotes: 13