I have been looking at the query resulting total number of employees under an superior emp_id that has been passed to the query.
Example : for emp_id 1 he has '2,3,4,5' as reportees and under again for emp_id 3 there are '6,7' are reportess and again under emp_id 6 there are '8,9' are reportees and again under emp_id 9 there is a reportee '10'
Now when I pass the manger_id '1' to the Query I should get all 9 employees.
Below is my query, that is not working if there are 40 employees under an single employee.
SELECT manager_id,emp_id FROM users ,(SELECT @head := 2) head
WHERE FIND_IN_SET(manager_id, @head) > 0 AND @head := CONCAT(@head, "," , emp_id) ORDER BY manager_id
In my table structure there is a manager_id column for each emp_id
Please help either with the MySQL query of MySQL function.