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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
aumbrother Posted August 23, 2006 Author Share Posted August 23, 2006 Thanks, that works Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.