zoukankan      html  css  js  c++  java
  • MySQL inner join 和 left join 的区别

    看了网上一些讲的感觉还是云里雾里,不如自己实操一下。

    sql语句,left join

    select isad.type_id,
        isad.activity_id,
        isad.id,
        ist.type_name,
       f.status
        from
        inspection_store_activity_detail isad
        inner join inspection_store_type ist on isad.type_id = ist.id
        left join inspection_store_follow f on isad.id = f.activity_detail_id
    

      

    inner join 

    select isad.type_id,
        isad.activity_id,
        isad.id,
        ist.type_name,
            f.status
        from
        inspection_store_activity_detail isad
        inner join inspection_store_type ist on isad.type_id = ist.id
        inner join inspection_store_follow f on isad.id = f.activity_detail_id

     如图,inner join在连接的表在要查询的字段有空时,该条记录不会被查询出来,主表信息也不保留。

    left join 是主表信息都保留,连接的表有该字段展示,没有就展示null。

    下班记得打卡
  • 相关阅读:
    二分查找
    泛型 学习
    一个时间转换的功能的类
    TCP/IP、Http、Socket的区别
    值得学习的
    popupwindow使背景变暗
    设计模式最好的学习网站
    观察者模式
    数据报的使用
    网络编程server
  • 原文地址:https://www.cnblogs.com/onlyzhangmeng/p/13651186.html
Copyright © 2011-2022 走看看