 <p>COUNT is an aggregate function, you should use GROUP BY.</p> <p><a href="http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html</a></p>