I have a table that is laid out as below:
id - tag_id - post_id
1 - 1 - 3
2 - 1 - 6
3 - 1 - 2
4 - 2 - 3
5 - 2 - 9
6 - 1 - 7
I would like to write an mySQL statement that finds out how many times a tag is referenced.
I would then use PHP to format the results. tag # was referenced # times and they would be sorted in order of # times.
My ability with MySQL is limited to very basic SELECT, INSERT, UPDATE and DELETE statements, so I’m not sure of the way to go about this. Can you help?
This will order your results by count(*) in descending order, meaning the tags with most posts will appear on top rows.