MySQL中left join、right join與inner join的區別


1、數據庫

1.1、作者表

 

1.2、圖書表

1.3、出版社表

2、left join

  left join(左聯接) 返回包括左表中的所有記錄和右表中聯結字段相等的記錄。

2.1、sql語句

select * from app01_publisher left join app01_book on app01_publisher.id = app01_book.publish_id

 

2.2、查詢結果

3、right join

  right join(右聯接) 返回包括右表中的所有記錄和左表中聯結字段相等的記錄。

3.1、sql語句

select * from app01_publisher right join app01_book on app01_publisher.id = app01_book.publish_id

 

3.2、查詢結果

4、innner join

  inner join(等值連接) 只返回兩個表中聯結字段相等的行。

4.1、sql語句

select * from app01_publisher inner join app01_book on app01_publisher.id = app01_book.publish_id

 

4.2、查詢結果

 


免責聲明!

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



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