MySQL Forums
Forum List  »  Newbie

Counting from parent and child
Posted by: Pekka Ahola
Date: November 03, 2010 03:33AM

Hi,

I bet there is many topics from this same topic but couldn't find any help.

So I hava a table of assignments which has an id and a group_id and I have a group table which has an id, parent_id.

I want to show the total count of assignment grouped by parent and child, so that the parent group counts in also the childs assignments.

So if a have there is two groups g1 with id=1 and g2 with id=2 and parent_id=1 so g2 a child of the g1. In assignments a have one assignment with group_id=2

My problem is to get the sql for showing only g1 with the total count of assignmets to it and its childs. So the count for g1 is 1.

I've tried all kinds of joins but can't get it right.

Hope you understand what i ment and can help me

Options: ReplyQuote


Subject
Written By
Posted
Counting from parent and child
November 03, 2010 03:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.