André

> Sorry, my english sentence was imprecise. :) I want the count of all 
> sub-entries AND THEIR sub-sub-entries.

Example:

   A
  / \
  B C
   / \
   D E
      \
      F

So I want to know that C has 3 sub-nodes.


Aha! I thought it seemed like an easy question ;-)
As far as i know, the only way to do this is one of the methods you suggested - 
recursively adding up, or storing a count which is updated on insert/delete 
operations.

--Rob


> -----Ursprüngliche Nachricht-----
> Von: Rob Desbois [mailto:[EMAIL PROTECTED] 
> Gesendet: Mittwoch, 27. September 2006 15:48
> An: André Hänsel; mysql@lists.mysql.com
> Betreff: re: Count of children
> 
> André,
> 
> Your sentence 'I want the count of all sub-entries for a 
> specific entry' converts straight into SQL:
> 
> 'I want'
>     SELECT
> the count of all entries
>     COUNT(*) FROM myTable
> with a specific parent
>     WHERE parent_id = 5
> 
> You've missed one of the major benefits of SQL - it's 
> designed to read like an English sentence!
> --Rob
> 
> 
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email 
> ______________________________________________________________________
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    
> http://lists.mysql.com/[EMAIL PROTECTED]
> 


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


<

---------- Original Message ----------

FROM:      André Hänsel<[EMAIL PROTECTED]>
TO:        "'Rob Desbois'" <[EMAIL PROTECTED]>
DATE:      Wed, 27 Sep 2006 16:00:25 +0200

SUBJECT:   AW: Count of children

Sorry, my english sentence was imprecise. :) I want the count of all
sub-entries AND THEIR sub-sub-entries.

Example:

   A
  / \
  B C
   / \
   D E
      \
      F

So I want to know that C has 3 sub-nodes.


> -----Ursprüngliche Nachricht-----
> Von: Rob Desbois [mailto:[EMAIL PROTECTED] 
> Gesendet: Mittwoch, 27. September 2006 15:48
> An: André Hänsel; mysql@lists.mysql.com
> Betreff: re: Count of children
> 
> André,
> 
> Your sentence 'I want the count of all sub-entries for a 
> specific entry' converts straight into SQL:
> 
> 'I want'
>     SELECT
> the count of all entries
>     COUNT(*) FROM myTable
> with a specific parent
>     WHERE parent_id = 5
> 
> You've missed one of the major benefits of SQL - it's 
> designed to read like an English sentence!
> --Rob
> 
> 
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email 
> ______________________________________________________________________
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    
> http://lists.mysql.com/[EMAIL PROTECTED]
> 


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to