Write a query to display the department ID, department name ,manager id and first name of manager.
时间: 2024-05-04 16:17:05 浏览: 166
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.
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)