Write a query to display the department ID, department name ,manager id and first name of manager.
时间: 2024-05-04 21:17:05 浏览: 8
Assuming you are using a database with tables named "departments" and "employees", where the "departments" table has columns "dept_id", "dept_name", and "manager_id", and the "employees" table has columns "emp_id" and "emp_first_name", you can use the following SQL query to display the desired information:
```
SELECT d.dept_id, d.dept_name, d.manager_id, e.emp_first_name
FROM departments d
JOIN employees e ON d.manager_id = e.emp_id;
```
This query joins the "departments" table with the "employees" table on the "manager_id" and "emp_id" columns, and selects the relevant columns to display. The result will be a table with the department ID, department name, manager ID, and first name of the manager for each department.