Most commonly occurring string in mysql column.
- by MILESMIBALERR
I am making a website where users can vote on which category a page is. They can vote that the page is category, for example: a, b, c, or d. Please don't ask what I am using this for, it is not important, I just want to know how to do it.
I need to find the most commonly occurring category in the mysql row out of all the votes.
Each time a user submits their vote, it submits the "category" that they voted for, and the "page_id".
I have this so far:
select page_id, category
from categories
group by page_id
You cannot simply use a "COUNT(*) where category = 'a'" then repeat it for each category because there is many more categories in the actual project.