select e.name,d.depn from emp e ,dept d where e.id=d.id他和
select e.name,d.depn from emp e join dept d on e.id=d.id有什么区别呢
什么时候两个表间要用join连接符 什么时候不用加呢????
------解决方案--------------------
通俗一点
第一组是过滤模式 查询2表有关系的数据 没关联则不会显示出来
第二组是左连接 以左边为基表来关联右表 如果右表存在关系 右表字段就显示数据 不存在 就显示空 但是左边数据都会显示
------解决方案--------------------
------解决方案--------------------
举个简单的例子
- SQL code
--俩表tb1,tb2 with tb1 as( select 1 c1,'a' c2 from dual union all select 2 c1,'b' c2 from dual),tb2 as( select 1 c1,'aa' c2 from dual union all select 3 c1,'bb' c2 from dual)--第一种select a.c2,b.c2from tb1 a,tb2 bwhere a.c1 = b.c1 c2 c2------------------- a aa--第二种select a.c2,b.c2from tb1 a left join tb2 b on a.c1 = b.c1 c2 c2------------------- a aa b
------解决方案--------------------
这2条语句没有区别,都是内连接,只是写法不同而以,怎么写看你喜好