mysql 数据操作 多表查询 多表连接查询 内连接
内连接:只连接匹配的行
只取两张表共同的部分,相当于利用where 过滤条件从笛卡尔积结果中筛选出了正确的结果
select * from 左表 inner join 要连接的表 on 条件
#department没有204这个部门,因而employee表中关于204这条员工信息没有匹配出来
mysql> select * from employee inner join department on employee.dep_id = department.id; +----+-----------+--------+------+--------+------+--------------+ | id | name | sex | age | dep_id | id | name | +----+-----------+--------+------+--------+------+--------------+ | 1 | mike | male | 18 | 200 | 200 | 技术 | | 2 | alex | female | 48 | 201 | 201 | 人力资源 | | 3 | jack | male | 38 | 201 | 201 | 人力资源 | | 4 | yuanhao | female | 28 | 202 | 202 | 销售 | | 5 | liwenzhou | male | 18 | 200 | 200 | 技术 | +----+-----------+--------+------+--------+------+--------------+ 5 rows in set (0.01 sec)
select * from employee inner join department on employee.dep_id = department.id where
后面也可以加上where 过滤条件