At the moment I have a script that runs through links in several categories and orders them with the most recent first. The links are added at different times so some categories have more recent links than others. However, I want the same number of links from each category to be displayed, say 20, so I can't just limit the total number of links because the categories will not be balanced.
My previous solution was to query each category individually to obtain the results but with a large number of categories this is not efficient. So my question is, how can I focus this into one query and limit the number of results per category.
The important table details are:
Categories
---
cat_id
Links
---
link_id, cat_id
cat_id in both are linked together.
Many thanks.
My previous solution was to query each category individually to obtain the results but with a large number of categories this is not efficient. So my question is, how can I focus this into one query and limit the number of results per category.
The important table details are:
Categories
---
cat_id
Links
---
link_id, cat_id
cat_id in both are linked together.
Many thanks.