一、内外连接全连接,左右连接

 
█▓        通过两张表查找其对应的记录.

隐式 内连接 select * from a,b where a.列名 = b.列名

 
█▓        左连接

select * from a left
outer join b on a.id = b.id

 
█▓        右连接

select * from  a  right  outer  join b  on a.id = b.id

 
█▓        全连接

可以使用union来达到全外连接的查询效果。

union :可以将左外连接查询和右外连接查询两条sql语句使用union合并起来进行查询,去掉重复的数据。

 
select * from a left outer join b on a.id = b.id 
union
select * from a right outer join b on a.id = b.id
 
 
小结

内连接:

1、  隐式内连接:

Select * from a,b where a.id = b.id;

结果:C

2、  显示内连接:

Select * from a inner join b on a.id = b.id;

结果:C

外连接:

1、  左外连接

select * from a left outer join b on a.id = b.id

结果:A+C

2、  右外连接

select * from a right outer join b on a.id = b.id

结果:B+C

3、  union:相当于全外连接

select * from a left outer join b on a.id = b.id

union

select * from a right outer join b on a.id = b.id

结果:A+B+C,会自动虑重

select * from a left outer join b on a.id = b.id

union all

select * from a right outer join b on a.id = b.id

结果:A+B+C,有重复数据

█▓
 
█▓
 
 
█▓
 
 
█▓
 
█▓
 
█▓
 
 
█▓
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">

 
 
 
 

18mysql3的更多相关文章

随机推荐

  1. UIImageView - BNR

    继续上节UINavigationController - BNR. 打开BNRDetailViewController.xib文件,向view中添加UIImageView对象,选中该对象,通过Attr ...

  2. Ajax跨越问题原因分析与解决思路

    1.什么是AJAX跨域问题 简单来说,就是前端调用后端服务接口时 如果服务接口不是同一个域,就会产生跨域问题 2.AJAX跨域场景 前后端分离.服务化的开发模式 前后端开发独立,前端需要大量调用后端接 ...

  3. Javascript设计模式之我见:观察者模式

    大家好!本文介绍观察者模式及其在Javascript中的应用. 模式介绍 定义 定义对象间一种一对多的依赖关系,使得每当一个对象改变状态,则所有依赖于它的对象都会得到通知并被自动更新. 类图及说明 S ...

  4. netty同端口监听tcp和websocket协议

    前言: 软件通信七层结构(osi模型)中由协议套协议最终组成最高级应用层协议(http等等),下三层结构偏向与数据通信,上三层更偏向于数据处理,中间的传输层则是连接上三层与下三层之间的桥梁,每一层都做 ...

  5. 根据指定条件使CheckBox 无法选中

    var trList = $("#tab1").children("tr")for (var i=0;i<trList.length;i++) {var ...

  6. Python-模块导入-63

    模块导入: # 内置模块 # 扩展的 django # 自定义的 # 文件 # import demo # def read(): # print('my read func') # demo.rea ...

  7. hibernate坑边闲话

    使用hibernate各种各样的坑 Remember that ordinal parameters are 1-based node to traverse cannot be null 这两个错误 ...

  8. 使用matplotlib画饼图

    import matplotlib.pyplot as pltx = [4, 9, 21, 55, 30, 18]labels = ['math', 'history', 'chemistry', ' ...

  9. hibernate 的sum(filed)引发的NullPointException错误解决过程

    背景: 在用hql语句进行sum查询时遭遇NPE问题: StringBuilder builder = new StringBuilder("select SUM(actualWorking ...

  10. MySql实现分页查询的SQL,mysql实现分页查询的sql语句

    一:分页需求: 客户端通过传递start(页码),limit(每页显示的条数)两个参数去分页查询数据库表中的数据,那我们知道MySql数据库提供了分页的函数limit m,n,但是该函数的用法和我们的 ...