1.多表查询
一个最简单的多表查询表现形式
select table1.column,table2.column
from table1,table2
where table1.column1=table2.column2;
1.等值连接
这个例子也是一个内连接
内连接: 合并具有同一列的两个以上的表的行, 结果集中不包含一个表与另一个表不匹配的行
查看一个员工的名字,部门以及城市
select last_name,e.department_id,department_name,city
from employees e,departments d,locations l
where e.department_id=d.department_id and d.location_id=l.location_id
n个表连接需要n-1个连接条件,可以给表起别名来减少代码的长度
用join on 来实现多个表的连接
select employee_id,d.department_id,department_name,city
from employees e join departments d
on e.department_id=d.department_id
join locations l
on d.location_id=l.location_id
2.非等值连接
查看一个员工的工资在哪个等级
select employee_id,last_name,salary,grade_level
from employees e,job_grades j
where e.salar