Table A is as follows:
AID |
Anum |
1 |
a20110111 |
2 |
a20110112 |
3 |
a20110113 |
4 |
a20110114 |
5 |
a20110115 |
Table B is as follows:
BID |
Bname |
1 |
bName0111 |
2 |
bName0112 |
3 |
bName0113 |
4 |
bName0114 |
8 |
bName0118 |
One, left join ... on
MySQL statement:
SELECT * from a left JOIN b on a.aid = B.bid
The results are as follows:
AID |
Anum |
BID |
Bname |
1 |
a20110111 |
1 |
bName0111 |
2 |
a20110112 |
2 |
bName0112 |
3 |
a20110113 |
3 |
bName0113 |
4 |
a20110114 |
4 |
bName0114 |
5 |
a20110115 |
Null |
Null |
Description
A LEFT join is based on a record of a table, a can be viewed as the left-hand table, B can be viewed as the right table, and a left table is the Ieft join. In other words, the records in the left table (A) will all be represented, and the right table (B) will only display records for the compound search condition (in the example: A.aid = b.bid).
b tables where the records are insufficient are null.
Second, right join ... on
The MySQL statement is as follows:
SELECT * from a right JOIN b on a.aid = B.bid
The results are as follows:
AID |
Anum |
BID |
Bname |
1 |
a20110111 |
1 |
bName0111 |
2 |
a20110112 |
2 |
bName0112 |
3 |
a20110113 |
3 |
bName0113 |
4 |
a20110114 |
4 |
bName0114 |
Null |
Null |
8 |
bName0118 |
Description
Right join is the opposite of the result of the left join, this time based on the right-hand table (B), where a table is deficient with null padding.
Third, inner join ... on
The MySQL statement is as follows:
SELECT * from a INNER JOIN b on a.aid = B.bid
Equivalent to:
SELECT * from A, b WHERE a.aid = B.bid
The results are as follows:
AID |
Anum |
BID |
Bname |
1 |
a20110111 |
1 |
bName0111 |
2 |
a20110112 |
2 |
bName0112 |
3 |
a20110113 |
3 |
bName0113 |
4 |
a20110114 |
4 |
bName0114 |
Description
The inner join is not based on who, it just shows the records that qualify.
The left JOIN operation is used in any Frome phrase.