当前位置: 首页 > news >正文

黄骅住房和城乡建设局网站做篮球网站用的背景图

黄骅住房和城乡建设局网站,做篮球网站用的背景图,推广网信息发布平台,工商注册系统加班遇到一个SQL问题#xff0c;本想把别人的SQL改下成SparkSQL#xff0c;在YARN上运行#xff0c;然而数据一直对不上。 原SQL ⚠️说明#xff1a;a.id#xff0c;b.id没有空的#xff0c;数据1:1#xff0c;b.name可能存在空的 select a.id,b.id,b.name from tab…加班遇到一个SQL问题本想把别人的SQL改下成SparkSQL在YARN上运行然而数据一直对不上。 原SQL ⚠️说明a.idb.id没有空的数据1:1b.name可能存在空的 select a.id,b.id,b.name from table_a a left join table_b b on a.id b.id and b.is_delete 0 and b.name is not null where exists(select 1 from table_b c where a.id c.id and c.is_delete 0 ) 改后的 想法是既然exists过滤了为什么不直接inner join呢于是乎 select a.id,b.id,b.name from table_a a inner join table_b b on a.id b.id and b.is_delete 0 求助群友 问了下群友区别是我一直以为left join 后 b.name is not null并没什么用就没有带我问群友下面这两个SQL有什么区别 select * from table_a a left join table_b b on a.id b.id and b.is_delete 0 where exists(select 1 from table_b c where a.id c.id and c.is_delete 0 )select * from table_a a inner join table_b b on a.id b.id and b.is_delete 0 群友问AI的结果 这样的回答不太对 自悟 然后仔细去品味这两个SQL有什么不同 -- 1 select a.id,b.id,b.name from table_a a left join table_b b on a.id b.id and b.is_delete 0 and b.name is not null where exists(select 1 from table_b c where a.id c.id and c.is_delete 0 )-- 2select a.id,b.id,b.name from table_a a inner join table_b b on a.id b.id and b.is_delete 0 数据table_a id 1 2 3 数据table_b id name id_delete 1 aa 0 2 bb 0 3 NULL 0 结论 1sql计算后的会剔除掉 table_a 不符合 a.id c.id and c.is_delete 0 条件的数据。加上 name is not null。最后的数据会出现这两类情况 a.id,null,null # name为nullb表全部为空 a.id,b.id,b.name # 全部有值 a.id b.id b.name 1 1 aa 2 2 bb 3 NULL NULL 2sql计算后中则会出现这两类情况 a.id,b.id,null a.id,b.id,b.name # 全部有值 a.id b.id b.name 1 1 aa 2 2 bb 3 3 NULL 所以count的时候是没有问题的两个都可以如果是取具体的值有所区别。 拓展 如果a.id b.id 是1:n 呢? 数据table_a id 1 2 3 10 数据table_b id name id_delete 1 aa 0 1 NULL 0 2 bb 0 3 NULL 0 -- 1 select a.id,b.id,b.name from table_a a left join table_b b on a.id b.id and b.is_delete 0 and b.name is not null where exists(select 1 from table_b c where a.id c.id and c.is_delete 0 ) a.id b.id b.name 1 1 aa 2 2 bb 3 NULL NULL -- 2select a.id,b.id,b.name from table_a a inner join table_b b on a.id b.id and b.is_delete 0 a.id b.id b.name 1 1 aa 1 1 NULL 2 2 bb 3 3 NULL 所以如果count的时候1对n相对于1:1是有区别的。 最后 1菜就要学就要钻研。 2加班使人头疼头脑不灵光。 3具体问题具体分析。
http://www.pierceye.com/news/828418/

相关文章:

  • wordpress 手机端模板百度seo标题优化软件
  • 货架网站开发特卖网站设计
  • 网站首页设计图片简约简单的明星个人网站建设论文
  • 织梦程序来搭建网站vip视频解析网站建设
  • 网站的管理上海创新网站建设
  • 企业对比网站西安做网站公司怎么样
  • 网站开发好做还是平面好做商务网页设计与制作是什么
  • 个人业务网站带后台凡科网站建设分类模块怎么弄
  • 在百度做网站需要什么资料appstore正版下载
  • wordpress怎么做404页面合肥seo软件
  • 建设网站挂广告赚钱免费个人网站源码
  • 网站ico图标动漫设计学什么内容
  • fireworks做网站定制做网站费用
  • 建设门户网站所需优秀营销网站设计
  • 行业网站建设教程办一家建筑公司流程
  • 网站空间文件夹中企动力主要是做什么的
  • 亚马逊做qa的网站wordpress theme是什么
  • 网站开发的经费预算php网站超市源码下载
  • 深圳建设高端网站asp.net 获取网站的绝对路径
  • 做的网站没流量吗前端页面设计
  • 门户网站的优点在环评备案网站上做登记后会怎么样
  • 网站的内容规划怎么写网站做外链的具体步骤
  • 百度网站排名规则小程序网站建设y021
  • 中国建设银行国际互联网站国内排名前五的电商
  • 怎么查网站的空间商四川建设工程招标网
  • 网站建设比较好公司朝阳区互联网公司排名
  • 百度不收录网站吗网站开发php
  • 房产网站建设的功能wordpress php7拓展
  • 做网站代码用什么软件天津建设工程信息网天津
  • 网站开发工程师前景怎么样怎么做自己的网站?