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

dede自动一键更新网站wordpress注册不跳转

dede自动一键更新网站,wordpress注册不跳转,昆明建站网站资讯平台,一个软件开发团队需要哪些人目录 一、知识点 二、测试验证 三、引申 一、知识点 left join中关于where和on条件的知识点: 多表left join 是会生成一张临时表。on后面: 一般是对left join 的右表进行条件过滤,会返回左表中的所有行,而右表中没有匹配上的数…

目录

一、知识点

二、测试验证

三、引申


一、知识点

         left join中关于where和on条件的知识点:

  • 多表left join 是会生成一张临时表。
  • on后面: 一般是对left join 的右表进行条件过滤,会返回左表中的所有行,而右表中没有匹配上的数据直接补为null。
  • on后面:如果存在对左表的筛选条件,无论条件真假,仍返回左表中的所有行,只是会影响右表的匹配值。即:on中针对左表的限制条件只会影响右表的匹配内容,并不影响返回的左表行数。
  • where后面:是对两表连接后的数据进行筛选,一般是针对左表的筛选条件。

   例如下面的sql:关联表(右表)的筛选条件如果放置在on后面,则下面sql的执行顺序是:B先按照条件进行过滤,再与A表关联; 

#主表:A; 关联表:B  关联条件:A.id = B.id  筛选条件:B.id >1
A left join B on A.id = B.id and B.id >1;

    筛选条件如果放置在where后面,则下面sql的执行顺序是:A和B先关联,基于生成的临时表再进行where条件过滤。

#主表:A; 关联表:B  关联条件:A.id = B.id  过滤条件
A left join B on A.id = B.id  where  A.id <> 1

二、测试验证

         创建t1 ,t2 两张表

create table if not exists test1( id int comment '用户id',name string comment '用户姓名');insert overwrite table test1
values (1,'a1'),(2,'a2'),(3,'a3'),(4,'a4');create table if not exists test2( id int comment '用户id',province string comment '用户所在省份');insert overwrite table test1
values (1,'hainan'),(2,'beijing'),(5,'sichuan'),(6,'chongqing');
测试1:返回左表所有行,右表符合on条件可匹配上,不满足条件的直接补null
selecttest1.id,test1.name,test2.id,test2.province
from test1
left join test2on test1.id = test2.id;

测试2:on后面增加对右表的限制条件;结论:左表记录全部返回,右表筛选条件生效
selecttest1.id,test1.name,test2.id,test2.province
from test1
left join test2on test1.id = test2.id and test2.province = 'beijing';

测试3:where后面增加对右表的限制条件:where test2.province = 'beijing';
   结论:where后面是对最后的临时表进行记录筛选,行数可能会减少
selecttest1.id,test1.name,test2.id,test2.province
from test1
left join test2on test1.id = test2.id  where test2.province = 'beijing';

测试4:on中增加对左表的限制条件,不影响返回的行数,只影响右表的匹配内容。
selecttest1.id,test1.name,test2.id,test2.province
from test1
left join test2on test1.id = test2.id and test1.name = 'a1';
测试5:where后面增加对左表的限制条件:where test1.name ='a4' 结论:where条件是在最后临时表的基础上进行筛选,返回满足条件的行
selecttest1.id,test1.name,test2.id,test2.province
from test1
left join test2on test1.id = test2.idwhere test1.name = 'a4';

三、引申

        由上述的where和on之间的区别,引申出来的面试题: t1表和t2表的字段如图,计算以下两个sql的值。

--1.输出结果
select  t1.id,t2.id
from t1
left join t2 on t1.id = t2.id and t2.id <>2;--2.输出结果
select  t1.id,t2.id
from t1
left join t2 on t1.id = t2.id 
where t2.id <>2;

解析:

(1)on后面:跟着的是对右表的限制条件  t2.id <>2;

          结论:左表记录全部返回,右表筛选条件生效

  
with t1 as (select 1 as id union allselect 2 as id union allselect 3 as id
),t2 as (select 1 as id union allselect 2 as id union allselect 2 as id)select  t1.id,t2.id
from t1
left join t2 on t1.id = t2.id and t2.id <>2;

输出结果为:

(2)where后面:跟着的是对右表的限制条件  where t2.id <>2;

          结论:最后临时表的基础上进行筛选,最终返回符合where过滤条件的行;

          ps: sql中比较的结果一般有:true, false, null; 而where条件只会过滤出true的结果

with t1 as (select 1 as id union allselect 2 as id union allselect 3 as id
),t2 as (select 1 as id union allselect 2 as id union allselect 2 as id)select  t1.id,t2.id
from t1
left join t2 on t1.id = t2.id
where t2.id <>2;

输出结果为:

补充:

select (1>2)  --> FALSE
select (1<2)  --> true
select (1<null) --> null--所以,sql比较的结果会有三种:false, true, null
http://www.yayakq.cn/news/723893/

相关文章:

  • 东莞市网站建设黄山网站开发jidela
  • 租外国服务器做的网站要备案吗wordpress信息填写
  • icp备案综合查询网站网页设计站
  • 迅雷黄冈网站推广软件wordpress 回复某个人
  • 虚拟主机网站建设步骤?wordpress初音主题
  • 义乌网站建设制作商seo优化推广教程
  • 雪域什么网站是做电影的wordpress怎样删除admin
  • 网站建设网站制作公司宁波网站建设选择荣胜网络
  • 做网站找哪个公司好淘宝做短视频网站好
  • 网站建设专业导航网站域名禁止网站相关
  • 菜单宣传网站怎么做的网站增加域名备案
  • 西安做网站哪家便宜建站平台 绑定域名
  • 福州网站建设liedns网络运维服务平台
  • 做网站会遇到哪些问题中小型企业建设网站
  • 南昌网站建设招聘互联网保险的弊端
  • 我的世界有什么做的视频网站四川手机网站设计
  • 鲅鱼圈做网站云seo关键词排名优化软件
  • 桂林微信网站本科专业建设网站
  • 多导航织梦网站模板下载地址什么网站做推广效果好
  • 学建站wordpress怎么手动安装网站程序
  • 网站如何做地推网站诊断案例
  • 做网站找哪家好网站后台怎么做的
  • 建设电子商务网站的步骤漳州微信网站开发
  • 比较好的建站网站仿顺丰优选网站源码
  • 网站空间pdf下载不了中国执行信息公开网信息查询
  • 北京建站管理系统开发app网站有哪些
  • dede旅游网站百度关键词策划和seo的优化
  • 做网站公司深做外贸网站价格
  • vivo手机的网站开发monolith wordpress模板
  • 江西省飞宏建设工程有限公司 网站吉首网络推广