I have a table containing two fields: ID and USERNAME. How to my make the SELECT query that will select only rows with minimal two rows grouped?
This is what inside the MySQL table:
1 | peter
2 | jack
3 | peter
4 | ann
5 | peter
6 | jack
I want to select in result like this:
Username 'ann' will be ignored in selection cause it's only one row.
Added: Cannot implement it to my situation. Ok, I will show what I exactly want to do, something like this: (SELECT ip AS ip1 FROM ip_denylist) UNION (SELECT COUNT(user) AS sometotal FROM entrances WHERE ip = ip1 AND HAVING COUNT(sometotal) > 1) GROUP BY user.
But it's not working! Could you show how it must be?
The idea of this select is first: to select each ip address from the ip_denylist table, 2nd: select grouped by user rows from the table entrances that have same ip addresses.
SELECT UserName, COUNT(UserName) AS sometotal FROM table GROUP BY UserName HAVING COUNT(UserName) > 1