SQL Count Query In a Main Query
Posted on 2009-12-30
I have a Categories table. The table has an "ID", "Name" and "ID_Bond" field. It is like an endless tree. Every row is bound to another row with the ID_Bond field, it contains the ID of the main rows ID field.
I have a query like SELECT [Name] FROM Categories WHERE ID_Bond = 1. This returns all the sub rows of the row with ID=1.
My question is I need the sub categories count for each row that the query returns.
Something like SELECT [Name], (....) as _TotalSubCategoriesCount FROM Categories WHERE ID_Bond = 1.