Posted by Chris Brownbill on 09/21/05 15:50
Hilarion wrote:
>
> In another words: you want to count how many parents have children?
>
> SELECT count(*)
> FROM parent_table
> WHERE parent_table.parent_id IN (SELECT child_table.parent_id FROM
> child_table)
>
> or
>
> SELECT count(DISTINCT child_table.parent_id)
> FROM child_table
>
>
> Hilarion
>
> PS.: In the second case I assumed that the relationship is enforced, so
> there
> are no children that do not have valid parent_id set.
Thank you. The nested Select concept was what I was missing!
Navigation:
[Reply to this message]
|