zoukankan      html  css  js  c++  java
  • 左连接与右连接的区别

    左连接只影响右表,右连接只影响左表。左连接返回左表中的全部数据,只返回右表中满足where条件的,右连接返回右表的全部数据,只返回左表满足where条件的。

    左连接 (left join)

    select *  from table1 left join tbale2 on table1.id=table2.id
    

    这条sql语句返回结果 table1表中的数据全部返回 table2表中的数据只返回满足where条件的

    右链接 (right join)

    select * from table1 right join table2 on table1.id=table2.id
    

    这条sql语句返回结果 table2表中的数据全部返回 table1表中的数据只返回满足where条件的

    内连接 (insert join)

    select * from table1 inner join table2 on table1.id = table2.id
    

    这条sql语句返回结果 显示满足条件的数据 并不以谁为主表

  • 相关阅读:
    Ugly Numbers
    Present
    Out of Hay
    Stars(树状数组或线段树)
    Humble Numbers
    Wireless Network
    Rank List
    Argus
    食物链
    Antenna Placement
  • 原文地址:https://www.cnblogs.com/tudouxifan/p/9120162.html
Copyright © 2011-2022 走看看