How to find the highest number of times a value is in records?
For example, in a table I have created called 'likes', there are three
fields: id (irrelevant), user id (the id of the user), and post id (the id
of the post). Say I have numerous records and I want to find out which
post id is in the database the most number of times. To be clear, I am not
asking which record has the biggest number in the post id field. Rather,
I'm looking for which post id is listed the most times. For example, let's
say one post id (222) is in the database 7 times while every other post id
has been used 1 time each. I need to find the post id of 222 in this case.
If possible how could I find the top 5 post id's with the highest amount
of uses within the records?
No comments:
Post a Comment