How to calculate the number of immediate children for each node in an adjacency list
        Posted  
        
            by Travis
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Travis
        
        
        
        Published on 2010-06-15T03:10:06Z
        Indexed on 
            2010/06/15
            3:12 UTC
        
        
        Read the original article
        Hit count: 409
        
I have hierarchical data that I represent using the adjacency list model.
TABLE
    ID
    parentID
    title
I am wondering, what is the simplest way to SELECT the number of immediate children for each node? If possible, I'd like to do this in a single select, yielding a resultset like so...
RESULTS...
ID     title     childCount
1      test1     10
2      test2     2
3      test3     0
etc...
Thanks for your advice!
© Stack Overflow or respective owner