select employee_id,last_name,department_name,city
from employees,departments,locations
where employees.department_id=departments.department_id and
departments.location_id=locations.location_id;
/*
演绎式:发现提出一个问题----解决一个问题---发现提出第二个问题------解决第二问题---
*/
#多表查询的分类用的是归纳式
/*
角度1:等值链接 VS 非等值链接
角度2:自连接 (自我引用) VS 妃子链接
角度3: 内连接 VS 外连接
*/
select * from job_grades ;
#查询名字,月薪和对应的等级
#between and
select last_name ,salary , grade_level
from employees e, job_grades j
where e.salary between j.lowest_sal and j.highest_sal;
# 区间[]
select last_name ,salary , grade_level
from employees e, job_grades j
where e.salary >= j.lowest_sal and e.salary <= j.highest_sal;
#角度二:自连接 VS非自连接
select * from employees;
select emp.employee_id,emp.last_name, mgr.employee_id,mgr.last_name
from employees emp, employees mgr
where emp.manager_id= mgr.employee_id;