Home › Interview Questions › Given an employee table with columns employee_name…

Given an employee table with columns employee_name and manager_id, how would you write a query to display each employee’s name along with their manager’s name?

🟢 Easy Coding Junior level
1Times asked
Nov 2026Last seen
Nov 2026First seen

💡 Model Answer

Assuming the employee table has columns employee_id, employee_name, and manager_id, you can retrieve each employee’s name along with their manager’s name using a self‑join: SELECT e.employee_name AS employee, m.employee_name AS manager FROM employees e LEFT JOIN employees m ON e.manager_id = m.employee_id; The LEFT JOIN ensures that employees without a manager (top‑level managers) still appear with a NULL manager name. If you want to exclude those rows, use an INNER JOIN instead. This query returns a two‑column result set showing the reporting relationship for every employee.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500