MySql finds multiple rows with the same value in a column

I am writing down IP addresses in my database and I want to look at accounts that have the same IP address as eachother. I would like to show only results with more than one IP address. I prefer it to be sorted by the IP address that was used the most (IE, if I have 30 accounts with 127.0.0.1, since my ip I probably have that higher 10ip address that belongs to 192.168.1.123).

How to write this request? I am using mysql

+4
source share
1 answer
SELECT ip, COUNT(*) FROM Table GROUP BY ip HAVING COUNT(*) > 1 ORDER BY COUNT(*); 
+13
source

Source: https://habr.com/ru/post/1385376/


All Articles