I have two tables in SQL Server database:
category(
itemid,
parentid
)
ArticleAssignedCategories(
categid,
artid
)
categid
is a foreign key of itemid
I want to get count of artids
and child of that for given itemid
(child means categories with parentid
of given itemid
.)
For example; If given itemid = 1
and in table category
have (3,1),(4,1)(5,3)
All of 3, 4, 5 are child of 1
Can anyone help me to write a good query?