You are here: Re: Basic SQL question « PHP SQL « IT news, forums, messages
Re: Basic SQL question

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация