php - How to get count children of users -
i want count of chidren. try query not work table colums
id, father_id , name
select id parent_id , father_id ,name, count(select * users father_id = parent_id) child users
use correlated sub-query count:
select id parent_id , father_id ,name, (select count(*) users u2 u2.father_id = u1.id) child users u1
Comments
Post a Comment