In the SQL standard in planning (Join) approximately divided into the following four:
1. Internal link:
The link two tables in the relationship between the existence of the field in line with the relations linking
those records to form the link recordset.
2. External link:
two outside the left outer join and right join.
left join: Table A of all records and Table B of the field in connection with Table A of the link field in line
with the conditions of those records linking the records of the formation of the association set
The right join A, B and Left join B, A is the same as the result of table,for example:
Select A.name B.name From A Left Join B On A.id=B.id
And
Select A.name B.name From B Right Join A on B.id=A.id
The result is the same.
3. Full Join:
there will be two tables in the relationship between the field Join all the records set out the formation
of the association records
4. Not Join
MySQL support for Select and Update and Delete some circumstances Join grammar, syntax specific
details are as follows:
table_references: table_reference [, table_reference] … table_reference: table_factor | join_table table_factor: tbl_name [[AS] alias] [{USE|IGNORE|FORCE} INDEX (key_list)] | ( table_references ) | { OJ table_reference LEFT OUTER JOIN table_reference ON conditional_expr } join_table: table_reference [INNER | CROSS] JOIN table_factor [join_condition] | table_reference STRAIGHT_JOIN table_factor | table_reference STRAIGHT_JOIN table_factor ON condition | table_reference LEFT [OUTER] JOIN table_reference join_condition | table_reference NATURAL [LEFT [OUTER]] JOIN table_factor | table_reference RIGHT [OUTER] JOIN table_reference join_condition | table_reference NATURAL [RIGHT [OUTER]] JOIN table_factor join_condition: ON conditional_expr | USING (column_list)
More complex usage of the above, the problem lies in what is table_reference and table_factor?
Here is a table table_reference Reference, in MySQL, the join is a reference to the table, the need to
join the table is defined as table_reference, at the same time is also true in the SQL Standard. MySQL
and is table_factor Quoted on the functional enhancements and expansion, the table can be
referenced in brackets refer to a series of tables, such as the following examples:
Select * FROM t1 LEFT JOIN (t2, t3, t4) ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)
The results of the SQL and the following is the same:
Select * FROM t1 LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)
These two examples not only in our understanding of MySQL and table_factor meaning
table_reference,and understand some of the use CROSS JOIN. MySQL in the current version
of the role of CROSS JOIN and INNER JOIN is the same as.
ON and Where function about the same,but Here is just ON the table-specific JOIN.
You may also see the OJ table_reference LEFT OUTER JOIN table_reference this sentence,This
is not the standard MySQL written only to the SQL syntax and ODBC-compatible set of.

No Responses to “MySQL Multi-table queries Left Join and Right Join”