SQLServer inner join,left join,right join,outer join 备忘备忘
LEFT JOIN
LEFT JOIN 关键字会从左表那里返回所有的行,即使在右表中没有匹配的行。
即LEFT JOIN 的 ON 条件不会对数据行造成影响
RIGHT JOIN
RIGHT JOIN 关键字会从右表那里返回所有的行,即使在左表中没有匹配的行。
INNER JOIN
INNER JOIN 关键字会从右表那里返回所有的行,即使在左表中没有匹配的行。
INNER JOIN 的ON 条件会对数据行进行筛选
因此 INNER JOIN的 ON条件 放在ON后 或 WHERE后是一样的效果
从论坛里抄一句过来:
on是连接条件, where是过滤条件。
对内连接来说, 二者等价。
对外连接来说,
on影响侧输入的输出, 合连接条件则输出相应列值,不合则输出null, 对主输入无影响。
where影响结果集。
|
on是连接条件, where是过滤条件。
对内连接来说, 二者等价。 对外连接来说, select * from ta a left join tb on a.id=b.id and b.n is null select * from ta a left join tb on a.id=b.id where b.n is null |
|
on是连接条件, where是过滤条件。
对内连接来说, 二者等价。 对外连接来说, select * from ta a left join tb on a.id=b.id and b.n is null select * from ta a left join tb on a.id=b.id where b.n is null |
|
on是连接条件, where是过滤条件。
对内连接来说, 二者等价。 对外连接来说, select * from ta a left join tb on a.id=b.id and b.n is null select * from ta a left join tb on a.id=b.id where b.n is null |
|
on是连接条件, where是过滤条件。
对内连接来说, 二者等价。 对外连接来说, select * from ta a left join tb on a.id=b.id and b.n is null select * from ta a left join tb on a.id=b.id where b.n is null |
SQLServer inner join,left join,right join,outer join 备忘备忘的更多相关文章
- SQL中inner join、outer join和cross join的区别
对于SQL中inner join.outer join和cross join的区别简介:现有两张表,Table A 是左边的表.Table B 是右边的表.其各有四条记录,其中有两条记录name是相同 ...
- sqlite数据库执行full outer join
sqlite数据库执行full outer join时提示:RIGHT and FULL OUTER JOINs are not currently supported. sqlite数据库不支持(+ ...
- MySql Outer Join 简单化
查询from语句中的Outer Join可以在多种情况下被简化: 在解析阶段,右外连接操作可以被转变为等下ode值包含left join的操作,在一般情况下,转变: (T1, ...) RIGHT J ...
- 【转载】SQL中inner join、outer join和cross join的区别
对于SQL中inner join.outer join和cross join的区别很多人不知道,我也是别人问起,才查找资料看了下,跟自己之前的认识差不多, 如果你使用join连表,缺陷的情况下是inn ...
- hive中left join、left outer join和left semi join的区别
先说结论,再举例子. hive中,left join与left outer join等价. left semi join与left outer join的区别:left semi join相当 ...
- oracle 内连接(inner join)、外连接(outer join)、全连接(full join)
转自:https://premier9527.iteye.com/blog/1659689 建表语句: create table EMPLOYEE(EID NUMBER,DEPTID NUMBER,E ...
- “,”、“natural join”、“natural left outer join”、“natural right outer join”的用法总结
“,”:代表笛卡尔积: “natural join”:代表自然连接,即同名列等值连接: “natural left outer join”:表示左外连接: “natural right outer j ...
- SQL中inner join,outer join和cross join的区别
使用join连表,缺陷的情况下是inner join,开发中使用的left join和right join属于outer join,outer join还包括full join 现有两张表,Table ...
- left outer join的on不起作用
left outer join的on不起作用 Why and when a LEFT JOIN with condition in WHERE clause is not equivalent to ...
- Oracle Partition Outer Join 稠化报表
partition outer join实现将稀疏数据转为稠密数据,举例: with t as (select deptno, job, sum(sal) sum_sal from emp group ...
随机推荐
- (转)OpenLayers3基础教程——OL3 介绍interaction
http://blog.csdn.net/gisshixisheng/article/details/46808647 概述: 本节主要讲述OL3的交互操作interaction,重点介绍draw,s ...
- C# 共享页调用css
@RenderSection("Styles", required: false) @section Styles{ }
- day35-1 类的三大特性---继承,以及类的派生
目录 类的继承 继承的特性 类的派生 类的组合 类的继承 继承是为了拿到父类的所有东西 继承的特性 减少代码的冗余 Python中父类和子类的对应关系是多对多 使用__bases__方法获取对象继承的 ...
- Uoj 52. 【UR #4】元旦激光炮 神题+交互题
Code: #include "kth.h" #include<iostream> int minn(int x,int y){return x<y?x:y;}; ...
- pymysql.err.ProgrammingError: (1064)(字符串转译问题)
代码: sql = "insert into dm_copy(演出类型,演出场馆,剧目名称,演出地点,演出时间,演出票价,演出团体,创建时间, url)values('%s','%s','% ...
- 15.4 Task 异步匿名函数
Func<int, Task<int>> func = async x => { Console.WriteLine("starting x={0}" ...
- c++ STL - priority_queue优先队列详解
简述 普通的队列是一种先进先出的数据结构,元素在队列尾追加,而从队列头删除.在优先队列中,元素被赋予优先级.当访问元素时,具有最高优先级的元素最先删除.优先队列具有最高级先出 (first in, l ...
- 配置zabbix及安装agent
一.配置zabbix http://ip/zabbix/setup.php Next step Next step 输入数据库密码后,Next step Next step 默认用户名是Admin 密 ...
- 洛谷 P3819 松江1843路
题目描述 涞坊路是一条长L米的道路,道路上的坐标范围从0到L,路上有N座房子,第i座房子建在坐标为x[i]的地方,其中住了r[i]人. 松江1843路公交车要在这条路上建一个公交站,市政府希望让最多的 ...
- 转载 - AC自动机算法
出处:http://blog.csdn.net/niushuai666/article/details/7002823 AC自动机简介: 首先简要介绍一下AC自动机:Aho-Corasick aut ...