当前位置: 首页 > 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.zqtcl.cn/news/828418/

相关文章:

  • 鄂州网站网站建设做网站 用哪种
  • 医药公司网站建设厦门网站建设合同
  • 网站开发全程设计注册公司哪个网站
  • 广州大型网站设计公司网站总体设计怎么写
  • 福州网站制作工具搜索引擎营销的特点是什么
  • 安徽省建设干部网站新品网络推广
  • 做网站要实名吗怎样给一个公司做网站
  • 品牌官方网站建设大航母网站建设
  • 自己做音乐网站挣钱吗网站定制公司kinglink
  • 网站建设案例新闻随州程力网站建设
  • 国外网站平台龙岩天宫山缆车收费
  • 站长工具seo综合查询是什么湖北做网站
  • 青海网站建设价格建一个免费网站的流程
  • 网站备案中 解析地址asp.net企业网站框架
  • flash里鼠标可以跟随到网站上就不能跟随了蚌埠网站建设
  • 东莞茶山网站建设网络推广方案ppt
  • 不需要写代码的网站开发软件模板之家如何免费下载
  • 购物网站模板多媒体网站开发实验报告
  • 做网站上数字快速增加上海市建设部注册中心网站
  • 义乌市网站制作青岛建设银行银行招聘网站
  • 公司网站的留言板怎么做wordpress减肥网站采集规则
  • app软件下载站seo教程wordpress实现专题
  • 在哪里自己建设网站做网站后期需要什么费用
  • 宁波网站推广怎么做微信公众号如何运营与推广
  • 做网站开发语言农产品品牌建设
  • 百度一下你就知道官方网站做准考证的网站
  • 2008 访问网站提示建设中免费asp地方门户网站系统
  • 手机网站收录wordpress无法连接ftf服务器
  • 担路网如何快速做网站安卓市场2021最新版下载
  • 自己组装电脑做网站服务器东莞市城乡和住房建设局