MySQL COUNT where COUNT greater than

Using MySQL COUNT with GROUP BY gives the total occurrence of each value in the database as determined with what is Grouped by. See here or here for more information.

SELECT COUNT(*), name FROM results GROUP BY name

This returns all the values as determined however if you want to only return where the count values are greater than a number here is how:

SELECT COUNT(*) as the_count, name FROM results GROUP BY name HAVING the_count > 7

This query will return the `names` where `the_count` is greater than 7.

SELECT COUNT(*) as the_count, name FROM results GROUP BY name HAVING the_count < 5

This query returns `the_count` where under 5

This is just another simple way to better define your queries to retrieve only relevant data rather than the extra rows had you not further defined that the count should be more/less than a number.