标签:rtm 技术分享 asc art 表数 连接 HERE left join info
一.多表数据记录查询
department表
employee表
1.1 where条件连接
1 select e.name as 姓名,d.name as 部门 2 from employee as e,department as d 3 where e.dept_id=d.id
温馨小提示:仔细观察一下这排列顺序,李老师id是2,以此类推,明显默认是asc升序排序
2.2 inner join条件连接
1 -- 内联查询 2 select e.name as 姓名,d.name as 部门 3 from employee as e inner join department as d 4 on e.dept_id=d.id -- 连接条件
2.3 outer join外连接
department表
employee表
1 -- 外连接查询 2 select e.name as 姓名,d.name as 部门 3 from employee as e left outer join department as d 4 on e.dept_id=d.id
温馨小提示:仔细观察,因为左查询是以左表做基表,所以左表的所有数据会全部出现(陆老师没有dpet_id关联还是出现),右表的财务部没有出现(没有被关联到)
连接代码可简写为left join
标签:rtm 技术分享 asc art 表数 连接 HERE left join info
原文地址:https://www.cnblogs.com/zjm1999/p/10110622.html