Multi-table queries often involve table JOIN, mainly involving inner join, outer join: left join (or left outer join), right join (or right outer join ), full join and cross join: cross join. Inner join is also called equivalent link. Internal JOIN is exclusive, while outer join is inclusive. A temporary table in the middle is generated for table join queries, and then this temporary table is returned to the user. General SQL statements: SELECT (field name to be queried) FROM table 1 (JOIN TYPE) Table 2 ON (JOIN CONDITION) [other conditions for filtering temporary table records]; the query results of several JOIN modes differ roughly as follows: inner join: Only rows with the same connection fields in two tables are returned (that is, rows that meet the conditions); left join: return records that include all records in the left table and joined fields in the RIGHT table. right join: Return records that include all records in the RIGHT table and joined fields in the left table. full join: all records of two connected tables; cross join: returns the Cartesian product of all data rows without the WHERE clause. table 1: TAB_EMPIDEMP_NAMEDEPT1Eric Huang12Alice33Peter14Green Table 2: TAB_DEPTIDDEPT_NAME1 R & D department 2 Finance Department 3 International Business Department 4 General Management Department 5 sales department inner join method: SQL> SELECT t1. Emp_name, t2.dept _ nameFROM tab_emp t1INNERJOIN tab_dept t2ON t1.dept = t2.id; execution result: Analysis: When inner join is used, only records meeting the connection conditions are listed. left join: SQL> SELECT t1.emp _ name, t2.dept _ nameFROM tab_emp t1LEFTJOIN tab_dept t2ON t1.dept = t2.id; execution result: Analysis: When LEFT JOIN is used, the records in the left table and the RIGHT table with the same joined fields are all listed, and all the fields with the same JOIN fields in the RIGHT table are null. right join mode: SQL> SELECT t1.emp _ name, t2.dept _ nameFROM tab_emp t1RIGHTJOIN tab_dept t2ON t1.dept = t2.id; run Result: Analysis: When right join is used, all records in the RIGHT table and joined fields in the left table are returned ;, if all the fields with unequal connection fields in the left table are null, full join: SQL> SELECT t1.emp _ name, t2.dept _ nameFROM tab_emp t1FULLJOIN tab_dept t2ON t1.dept = t2.id; execution result: Analysis: we can see that when full join is used, all records in the left table will be returned, all records in the right table will be returned, and matched records will be listed directly, the record value of a side that does not match is null. cross join: It is worth noting that the syntax of this method is slightly different from other types, and the on clause cannot be used. SELECT * FROM [Table 1] cross join [Table 2] or SELECT * FROM [Table 1], [Table 2] SQL> SELECT t1.emp _ name, t2.dept _ nameFROM tab_emp t1CROSSJOIN tab_dept t2; analysis: the number of records returned at the end is the product of the number of records in two tables. This type of JOIN syntax does not require JOIN conditions. All rows in a table are connected to all rows in another table. The result is called a Cartesian product. Finally, in actual project development, cross join is rarely used. It cannot use the ON keyword. Generally, you can connect to obtain the new table data, use other clauses such as the where clause for filtering, group by clause for aggregation, and order by clause for sorting. If 'group by' is used for multi-table JOIN queries, the order of 'group by' must be the same as that of the fields listed in 'select. this may be because group by determines the table sorting method. If it is a left Outer Join and there is no corresponding link on the right, a null value must be filled. if the sorting method does not match, it will be disordered.