1

In an employee table, some rows have the same value for the reportsTo column.

employeeNumber | reportsTo
---------------|-----------------
1056           | 1002
1076           | 1002
1088           | 1056
1102           | 1056
1143           | 1056
...

I want to be able to show the employee numbers of employees who report to the same person as does a particular employee.

For e.g. I want to know the other employees who report to the same person as employeeNumber 1088

The output should be:

   | employeeNumber |
   |----------------|
   | 1088           |
   | 1102           |
   | 1143           |

What simple MySQL statement I can use to get this result?

1 Answer 1

1

One way by using a subquery that returns reportsTo of employeeNumber = 1088

select
from   employees
where  employee.reportsTo = (select reportsTo
                             from   employees
                             where  employeeNumber = 1088);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.