so I had this one SQL problem asked to me on a coding challenge and I initially understood it wrong. Basically given an Employee table, with a primary key being EmployeeID theres also a column named say ManagerID. That ManagerID references a primary key in the same Employee table. Let's say EmployeeID 1's Manager is EmployeeID 3 who has a manager with EmployeeID 4.
How would a query look like to list all the Employees next to their managers? I'm a novice when it comes to SQL but is there a way to do this with say a for/while loop since it's possible for a low level employee to link all the way up the chain of command many times?