https://dev.mysql.com/doc/refman/5.7/en/join.html
1、JOIN语法
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)
INNER JOIN和,(逗号)在无联合条件下是语义相同的:
两者都可以对指定的表计算出笛卡儿乘积(也就是说,第一个表中的每一行被联合到第二个表中的每一行)。
在MySQL中,CROSS JOIN 从语法上说与 INNER JOIN 等同,[INNER | CROSS]可以省略就变成了 JOIN。
内连接
[INNER] JOIN
外连接
LEFT [OUTER] JOIN
RIGHT [OUTER] JOIN