aumbrother Posted August 22, 2006 Share Posted August 22, 2006 Here is a tough one for you. Say, I have a table "categories" and a table "topics".Each category has thousands of topics in it. I want to write a join query that would display all categories with 10 top rated titles next to it.Here is what I have so far: [color=blue][b]SELECT[/b] c.title,t.title,[b]COUNT[/b](t.id) [b]AS[/b] topic_count[b]FROM[/b] category [b]AS[/b] c[b]LEFT JOIN ON[/b] t.category_id = c.id[b]GROUP BY[/b] c.id[b]ORDER BY[/b] topic_count [b]DESC[/b][/color]How do I modify this query so that it only gives me up to 10 topics per category?Thanks in advance Link to comment https://forums.phpfreaks.com/topic/18297-is-there-a-way-to-limit-number-of-records-per-join/ Share on other sites More sharing options...
fenway Posted August 22, 2006 Share Posted August 22, 2006 You'd probably need to JOIN in a dervied table. Link to comment https://forums.phpfreaks.com/topic/18297-is-there-a-way-to-limit-number-of-records-per-join/#findComment-78652 Share on other sites More sharing options...
aumbrother Posted August 23, 2006 Author Share Posted August 23, 2006 Thanks, that works Link to comment https://forums.phpfreaks.com/topic/18297-is-there-a-way-to-limit-number-of-records-per-join/#findComment-79287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.