oracle学习83-oracle之单行函数之多表查询

 

 

 

 

 

--多表查询 
select employees.employee_id,employees.department_id,departments.department_name
from  departments,employees
where employees.department_id=departments.department_id;

 

 

--多表查询 其他情况
select e.employee_id,e.department_id,d.department_name
from  departments d,employees e
where e.department_id=d.department_id;
 
--多表查询 其他情况
select employee_id,e.department_id,department_name
from  departments d,employees e
where e.department_id=d.department_id;

 --员工在什么城市工作 三个表连接
select employee_id,e.department_id,department_name,city
from  departments d,employees e,locations l
where e.department_id=d.department_id and d.location_id=l.location_id

 

 

--根据档次转换 非等式连接
select employee_id,last_name,salary,grade_level from employees e,job_grades j
where e.salary between j.lowest_sal and j.highest_sal

 外连接

 

 

--多表查询 外连接
select employee_id,e.department_id,department_name
from  departments d,employees e
where e.department_id=d.department_id(+)

 

--多表查询 右外连接
select employee_id,e.department_id,department_name
from  departments d,employees e
where e.department_id(+)=d.department_id

 

 

--自然连接
select employee_id,department_id,department_name
from employees join departments
using(department_id)

 

--自然连接
select employee_id,d.department_id,department_name
from employees e join departments d
on e.department_id=d.department_id
--自连接
--查询公司中员工'chen'的manager信息
select emp.last_name,manager.last_name,manager.salary,manager.email
from employees emp,employees manager
where emp.manager_id=manager.employee_id and lower(emp.last_name)='chen'

 

posted @ 2022-08-13 21:29  前端导师歌谣  阅读(34)  评论(0)    收藏  举报