Count of children

2006-09-27 Thread André Hänsel
I have a table with id and parent_id. I want the count of all sub-entries for a specific entry. I found several documents about working with graphs/trees in MySQL but I could not find a solution for my problem. I can imagine two possibilities, but one is memory intensive and the other one

Re: Count of children

2006-09-27 Thread Jo�o C�ndido de Souza Neto
You can use it: SELECT parent_id, count( * ) FROM table WHERE parent_id =1 GROUP BY parent_id It´ll works fine. André Hänsel [EMAIL PROTECTED] escreveu na mensagem news:[EMAIL PROTECTED] I have a table with id and parent_id. I want the count of all sub-entries for a specific entry. I found

re: Count of children

2006-09-27 Thread Rob Desbois
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

AW: Count of children

2006-09-27 Thread André Hänsel
] 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

re: AW: Count of children

2006-09-27 Thread 'Rob Desbois'
; 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

Re: Count of children

2006-09-27 Thread Jo�o C�ndido de Souza Neto
/ \ 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

Re: Count of children

2006-09-27 Thread Peter Brawley
André, I want the count of all sub-entries for a specific entry. Depends on the model you are using--edge list or nested sets? PB - André Hänsel wrote: I have a table with id and parent_id. I want the count of all sub-entries for a specific entry. I found several documents about

AW: Count of children

2006-09-27 Thread André Hänsel
. September 2006 16:49 An: André Hänsel Cc: mysql@lists.mysql.com Betreff: Re: Count of children André, I want the count of all sub-entries for a specific entry. Depends on the model you are using--edge list or nested sets? PB - André Hänsel wrote: I have a table with id

Re: Count of children

2006-09-27 Thread Douglas Sims
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

Re: AW: Count of children

2006-09-27 Thread ddevaudreuil
I've found this website to be extremely helpful: http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html Donna DeVaudreuil André Hänsel [EMAIL PROTECTED] 09/27/2006 10:55 AM To [EMAIL PROTECTED] cc mysql@lists.mysql.com Subject AW: Count of children I will use any model

Re: AW: Count of children

2006-09-27 Thread Peter Brawley
in either of them. -Ursprngliche Nachricht- Von: Peter Brawley [mailto:[EMAIL PROTECTED]] Gesendet: Mittwoch, 27. September 2006 16:49 An: Andr Hnsel Cc: mysql@lists.mysql.com Betreff: Re: Count of children Andr, I want the count of all sub-entries for a specific

RE: AW: Count of children

2006-09-27 Thread Robert DiFalco
Hänsel Cc: mysql@lists.mysql.com Subject: Re: AW: Count of children André With an edge list, the solution entails recursion, so you need either an sproc or application proc. With a nested sets model, the count is dead simple. If the id of the target row is N, and the left right node columns