首页 > 其他分享 >子查询

子查询

时间:2022-12-15 19:12:41浏览次数:52  
标签:last name employees 查询 department zlotkey

用法:

内部嵌套一个查询

案例:查询和zlotkey相同的员工姓名和工资

1.查询zlotkey的部门

select department_id 

from employees

where last_name = 'zlotkey'

2.查询部门号=1的姓名和工资

select last_name,salary

from employees 

where department_id =(

  select department_id 

  from employees

  where last_name = 'zlotkey'

)

标签:last,name,employees,查询,department,zlotkey
From: https://www.cnblogs.com/liujy2233/p/16985855.html

相关文章