Explanation: In the statement, A is on the left side of B, and it is a Left Join, so the operation method is: A left join B records = Figure 3 public part record set C + table A record set A1
In Figure 3, that is, the Aid that exists in record set C is: 2 3 6 7 8
In Figure 1, that is, the Aid that exists in all record sets A of table A is: 1 2 3 4 5 6 7 8 9
The Aid that exists in the record set A1 of table A=(In Figure 1, it is all the Aid in table A)-(In Figure 3, it is the Aid that exists in the record set C). The final result is: 1 4 5 9
From this, we can conclude that the records of A left connected to B in Figure 5 = the public part record set C in Figure 3 + the record set A1 of table A. The final result can be seen in Figure 5 that Bnameid and Bid are not NULL. The records are all in the record set C in the public part of Figure 3; the four records with Bnameid and Bid as NULL and Aid as 1 4 5 9 are the Aids that exist in the record set A1 of table A.
(2) Right JOIN: That is, the public part record set C in Figure 3 + the record set B1 of table B.
The statement is as follows: select * from A Right JOIN B ON A.Aid=B.Bnameid The running result is shown in Figure 6 below:
Figure 6: Right join data
Description: In the statement, A is to the left of B and is a Right Join, so the operation method is: A right join B records = Figure 3 public part record set C + table B record set B1
In Figure 3, the Aid that exists in record set C is: 2 3 6 7 8
In Figure 2, the Bnameid that exists in all record sets B of table B is: 2 3 6 7 8 11
Table The Bnameid that exists in the B record set B1 = (in Figure 2, that is, all the Bnameids in the B table) - (in Figure 3, that is, the Aid that exists in the record set C). The final result is: 11
This leads to Figure 6 The records of the right connection of A in B = the public part record set C in Figure 3 + the table B record set B1. The final result can be seen in Figure 6 that the non-NULL records of Aid and Aname are all in the public part record set C of Figure 3. Record; the record with Aid and Aname as NULL and Aid as 11 is the Bnameid that exists in the record set B1 of table B.
Cross connection: When two tables are joined without conditions, the number of entries = Figure 1 * Figure 2
The above is the detailed content of What is the difference between inner join, left outer join, right outer join and cross join?. For more information, please follow other related articles on the PHP Chinese website!