谈谈oracle里的join、left join、right join、full join-版本2
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了谈谈oracle里的join、left join、right join、full join-版本2,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2550字,纯文字阅读大概需要4分钟。
内容图文
![谈谈oracle里的join、left join、right join、full join-版本2](/upload/InfoBanner/zyjiaocheng/476/9e7e85c68976400d85c4fc30e7625f32.jpg)
--1.left join 左表为主表,左表返回全部数据,右表只返回与左表相匹配的数据
select t1.fpdm,t1.fphm ,t1.zjr,t1.zjsj,t1.zjjx,t1.zjje,t1.zflx,t1.zfid,t2.fpdm,t2.fphm,t2.zflx from yw_zjfpjl t1
left join xxdzmx t2 on t2.fpdm||t2.fphm=t1.fpdm||t1.fphm
select t1.fpdm,t1.fphm ,t1.zjr,t1.zjsj,t1.zjjx,t1.zjje,t1.zflx,t1.zfid,t2.fpdm,t2.fphm,t2.zflx from yw_zjfpjl t1 , xxdzmx t2 where t2.fphm=t1.fphm(+)
--2.right join 右表为主表,右表返回全部数据,左表只返回与右表相匹配的数据
select t1.fpdm,t1.fphm ,t1.zjr,t1.zjsj,t1.zjjx,t1.zjje,t1.zflx,t1.zfid,t2.fpdm,t2.fphm,t2.zflx from yw_zjfpjl t1
right join xxdzmx t2 on t2.fpdm||t2.fphm=t1.fpdm||t1.fphm
--3.inner join 只返回两表相匹配的数据
select t1.fpdm,t1.fphm ,t1.zjr,t1.zjsj,t1.zjjx,t1.zjje,t1.zflx,t1.zfid, t2.fphm,t2.fpdm,t2.zflx from yw_zjfpjl t1
inner join xxdzmx t2 on t2.fphm||t2.fpDm = t1.fphm||t1.fpdm
where t2.fphm is not null and t2.zflx=‘0‘ and t1.zflx=‘0‘ and TO_CHAR(t1.zjsj,‘YYYY-MM‘)=‘2016-10‘ and substr(t2.dzyf, 0, 4)||‘-‘||substr(t2.dzyf, 5, 2)=‘2016-10‘;
--4.full join
--4.1全部结果集 106
select t1.fpdm,t1.fphm ,t1.zjr,t1.zjsj,t1.zjjx,t1.zjje,t1.zflx,t1.zfid,t2.fpdm,t2.fphm,t2.zflx from yw_zjfpjl t1
full join xxdzmx t2 on t2.fpdm=t1.fpdm and t2.fphm=t1.fphm
--4.2右边有左边没有 10-1=9
select t1.fpdm,t1.fphm ,t1.zjr,t1.zjsj,t1.zjjx,t1.zjje,t1.zflx,t1.zfid,t2.fphm,t2.fpdm,t2.zflx,t2.dzyf from yw_zjfpjl t1
full join xxdzmx t2 on t2.fphm||t2.fpDm = t1.fphm||t1.fpdm
where t2.fphm is not null and t2.zflx =0 and substr(t2.dzyf,1 ,4)||‘-‘||substr(t2.dzyf,5,2)=‘2016-10‘
--4.3左边有右边没有 97-1=96
select t1.fpdm,t1.fphm ,t1.zjr,t1.zjsj,t1.zjjx,t1.zjje,t1.zflx,t1.zfid,t2.fphm,t2.fpdm,t2.zflx from yw_zjfpjl t1
full join xxdzmx t2 on t2.fphm||t2.fpDm = t1.fphm||t1.fpdm
where (t1.zflx=‘0‘ and TO_CHAR(t1.zjsj,‘YYYY-MM‘)=‘2016-10‘ );
--4.4左边有右边没有 右边有左边没有 (97-1)+(10-1)=105
select t1.fpdm,t1.fphm ,t1.zjr,t1.zjsj,t1.zjjx,t1.zjje,t1.zflx,t1.zfid,t2.fphm,t2.fpdm,t2.zflx,t2.dzyf from yw_zjfpjl t1
full join xxdzmx t2 on t2.fphm||t2.fpDm = t1.fphm||t1.fpdm
where (t2.fphm is not null and t2.zflx =‘0‘ and substr(t2.dzyf,1 ,4)||‘-‘||substr(t2.dzyf,5,2)=‘2016-10‘) or (t1.zflx=‘0‘ and TO_CHAR(t1.zjsj,‘YYYY-MM‘)=‘2016-10‘ );
谈谈oracle里的join、left join、right join、full join-版本2
标签:substr -- sub rom 版本 str acl select oracle
本文系统来源:http://www.cnblogs.com/iyoume2008/p/6407711.html
内容总结
以上是互联网集市为您收集整理的谈谈oracle里的join、left join、right join、full join-版本2全部内容,希望文章能够帮你解决谈谈oracle里的join、left join、right join、full join-版本2所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。