gpt4 book ai didi

mysql - 在外部查询中显示department_name - sql

转载 作者:行者123 更新时间:2023-11-29 17:55:17 25 4
gpt4 key购买 nike

我有这个查询

select last_name,job_id,department_id
from empl_demo
where (department_id) in
(select department_id
from departments
where department_id=60);

我的问题是如何显示部门表中的“department_name”?例如:

select last_name,job_id,department_id,department_name
from empl_demo, departments;

但要符合我的条件

谢谢

最佳答案

经典的 INNER Join,您确实需要阅读一些基础 SQL 类(class)(例如 https://www.w3schools.com/sql/ )。

SELECT e_d.last_name,
e_d.job_id,
e_d.department_id,
d.department_name
FROM empl_demo e_d
INNER JOIN departments d on d.department_id = e_d.department_id
where department_id=60

关于mysql - 在外部查询中显示department_name - sql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48908924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com