join is divided into: inner join (INNER join), outer join (OUTER join). Among them, the outer join is divided into: left outer connection (OUTER join), right outer join (OUTER join), full outer join (complete OUTER join), where the "OUTER" keyword of the outer connection can be omitted from writing.
Example: table A has column ID, the value is: 1 2 3 4
Table B has column IDs, with values of: 3 4 5 6
1. Internal connection (shows the data that the left and right two tables can match exactly):
Select a.ID, b.id from A INNER JOIN B on a.id = b.id
The result is: 3 3 4 4
2. Left outer connection (displays all data on the left table, the right table does not match the display as NULL):
Select a.ID, b.id from A left JOIN B on a.id = b.id
Result: 1 null 2 NULL 3 3 4 4
3. Right outer connection (displays all data in the right table, the left table does not match the display as NULL):
Select a.ID, b.id from A right JOIN B on a.id = b.id
Result: 3 3 4 4 null 5 NULL 6
4. Full outer connection (displays all data on both the left and right sides of the table, NULL if the two tables do not match):
Select a.ID, b.id from A full OUTER JOIN B on a.id = b.id
Result: 1 null 2 NULL 3 3 4 4 null 5 NULL 6
Usage of joins in SQL Server