left join returns records that include all records in the left table and the equivalent of the junction fields in the right table. The right join returns records that include all records in the right table and the equivalent of the junction fields in the left table inner join (equivalent join) returns only two Examples of rows with equal junction fields in the table are:--------------------------------------------Table A is recorded as follows: AID Anum1a200501112a200501123a200501134a200501145a20050115 table B is recorded as follows: BID bname1 20060324012 20060324023 20060324034 20060324048 2006032408------------------------------------------ --1The . LEFT JOIN SQL statement is as follows: Select*From A left join B on A.aid=b.bid results are as follows: AID anum BID bname1 a20050111 1 20060324012 a20050112 2 20060324023 a20050113 3 20060324034 a20050114 4 20060324045a20050115 NULL null (the number of rows affected is5rows) The results show that the left join is based on the records of a table, a can be regarded as the right table, and B can be regarded as left table. In other words, the records of the left table (A) will all be represented, and the right table (B) will only display records that match the search criteria (in the example: A.aid=b.bid). The low-record of table B is null.--------------------------------------------
2The right join SQL statement is as follows: Select*From A right join B on A.aid=b.bid results are as follows: AID anum BID bname1 a20050111 1 20060324012 a20050112 2 20060324023 a20050113 3 20060324034 a20050114 4 2006032404NULL NULL8 2006032408(the number of rows affected is5result Description: Look closely, you will find that the result of the left join is exactly the opposite, this time is based on the right table (B), a table is not enough to fill with null.--------------------------------------------3The . INNER JOIN SQL statement is as follows: Select*From A innerjoin B on A.aid=b.bid results are as follows: AID anum BID bname1 a20050111 1 20060324012 a20050112 2 20060324023 a20050113 3 20060324034 a20050114 4 2006032404The results show: Obviously, this shows only the A.aid=B.bid Records. This shows that inner join is not based on who, it only shows records that match the criteria.--------------------------------------------
The difference between MySQL left join,right Join,inner join