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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -