一、内连接查询语法
隐式内连接
SELECT 字段列表 FROM 表1,表2 WHERE 条件...;
显示内连接
SELECT 字段列表 FROM 表1 [INNER] JOIN 表2 ON 连接条件...;
内连接查询的是两张表交集的部分
二、内连接演示
1.查询每一个员工的姓名,及关联的部门的名称(隐式内连接实现)
表结构:participators,department
连接条件:participators.dept_id = department.id
sql
select participators.name, department.name
from participators,
department
where participators.dept_id = department.id
order by participators.id;
sql
select p.name, d.name
from participators p, # 起别名
department d
where p.dept_id = d.id
order by p.id;
2.查询每一个员工的姓名,及关联的部门的名称(显式内连接实现) --- INNER JOIN ... ON ...
表结构:participators,department
连接条件:participators.dept_id = department.id
sql
select p.name, d.name
from participators p
inner join department d on p.dept_id = d.id
order by p.id;
sql
select p.name, d.name
from participators p
join department d on p.dept_id = d.id
order by p.id;