一、連接符分類,內連接,外連接
1、內連接:Inner Join簡寫Join。
2、外連接:Left Outer Join 簡寫Left Join;Right Outer Join 簡寫Right Join;Full Outer Join 簡寫Full Join。
二、用集合的形式展示各個連接符的特點
1、准備測試表Test_StudentA,Test_StudentB
2、Join,返回Test_StudentA與Test_StudentB集合的交集。
3、Left Join, 返回左表Test_StudentA的全集,右表匹配連接條件有值,不匹配賦NULL值。
4、Right Join,返回右表Test_StudentB的全集,左表匹配連接條件有值,不匹配賦NULL值。
5、Full Join,返回左表Test_StudentA,右表Test_StudentB的全集,不匹配連接條件賦NULL值。
三、數據庫中展現Join,Left Join,Right Join,Full Join的不同
1、Join,返回左表與右表符合ON連接條件的行。
如:select * from Test_StudentA join Test_StudentB on Test_StudentA.id=Test_StudentB.id
2、Left Join, 以左表為基表,返回左表所有行。若右表不符合ON連接條件,則對應的字段賦NULL值。
如:select * from Test_StudentA left join Test_StudentB on Test_StudentA.id=Test_StudentB.id
3、Right Join,以右表為基表,返回右表所有行。若左表不符合ON連接條件,則對應的字段賦NULL值。
如:select * from Test_StudentA right join Test_StudentB on Test_StudentA.id=Test_StudentB.id
4、Full Join,返回左右表所有行,不符合on條件的字段賦NULL值。
如:select * from Test_StudentA full join Test_StudentB on Test_StudentA.id=Test_StudentB.id