1. What is join
Join: Join indicates the relationship between two tables. we can regard two tables as two sets. Suppose there are two tables, which are represented by a and B. The two tables have one or more identical fields. There are three different sets:
1. Intersection: records with equal fields in two tables
2. A to B supplement: records with the same field content not equal to B in
3. B submits a supplement: records with the same field content not equal to a in B
2. query by join
Three Join Operations correspond to the preceding three sets.
1. Intersection: inner join Internal join
2. A to B complement: left join
3. B cross a complement: Right join right join
Iii. Instances
Now let's look at an instance. There are two tables, table 1: address; table 2: email.
For simplicity, both tables have only one field, and the field name is "name ". Now we can get three sets:
1. There is a name record in both tables.
Select address. Name: As name
From Address inner join email on address. Name = Email. Name;
2. records with a name in the address and no name in the email
Select address. Name
From address left join email on address. Name = Email. Name
Where (email. Name) is null ));
Note: This is a left join for the address table and a right join for the mail table.
3. Records with no name in the address and a name in the email
Select email. Name
From address right join email on address. Name = Email. Name
Where (address. Name) is null ));