資料庫的外連線 內連線 左外連線,全外連線

2022-09-06 10:51:16 字數 568 閱讀 1307

students表和advisors表

一、內連線

按照advistor_id進行表的合併,合併後的資料只有兩個表中advistor_id都有的值,對應的行

二、左外連線

按照advistor_id進行的左外連線合併,保證表students中advistor_id的每一列都在合併後的新錶中,對於advistors表中沒有的資料,填null

三、全外連線:

新錶中有原來兩個表中的所有資料,advistor_id中找不到對應值的項填null

參考:

內連線,左外連線,右外連線,全連線

1.內連線我們通常用的連線,表表連線只顯示交集資料 2.外連線分左外連線 table1 left outer join on table2 和右外連線table1 right outer join on table2 和全連線 table1 full outer join on table2 2.1...

資料庫 左外連線 右外連線 內連線

資料庫 左外連線 1.左外連線的主表在左邊,即連線兩個表時,保留左表中的不匹配部分,右表的相應項用null 或0 值表示。如圖 表ax 表bx from bx left outer join ax 左表,是指from 句中的左邊的表 bx.on ax.id bx.id 結果如圖 2.右外連線 右表的...

MySQL內連線 左外連線 右外連線 全外連線

連線的優勢是減少了外來鍵的使用。內連線 最常見的等值連線,指連線結果僅包含符合連線條件的行,參與連線的兩個表都應該符合連線條件。inner join或join on condition 首先建立兩個表person和card,內容如下 select from card id cardname 1 ca...