一.内连接
-- 多表查询
select * from tb_emp,tb_dept where tb_emp.dept_id = tb_dept.id;-- ================================================== 内连接 ===========================================
-- A.查询员工的姓名,及所属的部门名称(隐式内连接实现)
select tb_emp.name as '员工姓名',tb_dept.name as '部门名称' from tb_emp,tb_dept where tb_dept.id = tb_emp.dept_id;-- 起别名 起别名之后,就要使用别名,否则会报错
select e.name as '员工姓名', d.name as '部门名称' from tb_emp e ,tb_dept d where e.dept_id = d.id;-- B.查询员工的姓名,及所属的部门名称(显示内连接实现)
select e.name as '员工姓名', d.name as '部门名称' from tb_emp e inner join tb_dept d on e.dept_id = d.id;