Need a simple mysql query to know the subordinate employee in a organisation. I have created a table which looks as shown below:
emp_code level reporting_to emp001 0 emp001 emp002 1 emp001 emp003 2 emp002 emp004 3 emp001 emp005 3 emp003 emp006 3 emp003 emp007 3 emp001
I need a query using which, I can know the subordinate employees of a given employee, by giving the employee code.
For example, for emp001 all employees will be displayed, for emp002 will list emp003, emp005, emp006 and for emp003 only emp005, emp006 will be displayed.
Thanks in advance.