左連接和右鏈接的區別?


左連接只影響右表,右鏈接只影響左表。
 
左連接   (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語句返回結果   顯示滿足條件的數據   並不以誰為主表


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM