zoukankan      html  css  js  c++  java
  • 通俗易懂的join、left join、right join、full join、cross join

    内连接:列出与连接条件匹配的数据行(joininner join)

    外连接:两表合并,如有不相同的列,另外一个表显示null(left join ight joinfull outer joincross join)

    以学生表:#table1和课程表:#table2为例  

                

    select * from #table1 stu join #table2 cou on stu.student_id = cou.stu_id;
    Join

    Inner join 等于join(当条件都满足时,列出满足条件的项)

    执行结果和用where相同()

    select * from #table1 stu left join #table2 cou on stu.student_id = cou.stu_id;
    Left Join

    left join :以左表为主,右表没有的项显示null;

    select * from #table1 stu right join #table2 cou on stu.student_id = cou.stu_id;
    Right Join

    right join:以右表为主,左表没有的项显示null;

    select * from #table1 stu full outer join #table2 cou on stu.student_id = cou.stu_id;
    Full Outer Join

    full outer join : 没有主次表之分,显示所有,相当于左、右连接的组合;

    在Sql server数据库中,full join 和 full outer join(其他数据库没试过) 

    select * from #table1 stu full join #table2 cou on stu.student_id = cou.stu_id; ——结果和full outer join 一样;

    select * from #table1 cross join #table2 ;
    Cross Join

    cross join(交叉连接笛卡儿积):返回左表中的所有行,左表中的每一行与右表中的所有行组合;

         

  • 相关阅读:
    流量分析 (WireShark)
    WEB小技俩
    PHP伪协议
    php弱类型基础
    宽字节注入
    布尔盲注
    时间盲注
    Odoo13教程-Odoo快捷键使用_江苏欧度软件
    Odoo,快速上手Odoo,来了解Odoo几个标准模块
    开源Odoo13更新的模块功能信息(译文)
  • 原文地址:https://www.cnblogs.com/Duancf/p/11453611.html
Copyright © 2011-2022 走看看