Alex Chapp Alex Chapp - 7 months ago 77
MySQL Question

mySQL count only returning one result unless using group by

using the SQL query

select,count( as 'followers'
from user u,follow f
where u.type = 'c' AND f.followee =
group by

gets me the correct value for all users in my database, however, the exact same query without the group by line only gives me the first value. I am learning SQL for the first time and was having a hard time figuring out why this is.


When you use count without group by it will count all the records and returns single line while when you use count with group by it will group the users on the base of their names and returns the count of each group.