1, INNER join (typical join operation, using a comparison operator like = or <>). Includes equality joins and natural joins. Inner joins use comparison operators to match rows in two tables based on the values of the columns that are common to each table. For example, retrieve all lines of the students and courses table with the same student identification number. 2, outer joins. An outer join can be a left outer join, a right outer join, or a full outer join. When you specify an outer join in the FROM clause, you can specify by a group of the following groups of keywords: 1) The result set of the left JOIN or Ieft OUTER join, including all rows of the left table specified in the leftmost OUTER clause, is not just the row matching the Join column. If a row in the left table does not have a matching row in the right table, all select list columns in the right table in the associated result set row are null values. 2) The right join or OUTER join is the reverse join of the left outer join. All rows of the right table will be returned. If a row in the right table does not have a matching row in the left table, a null value will be returned for left table. 3) Full join or fully OUTER join complete outer JOIN returns all rows from the left and right tables. When a row does not have a matching row in another table, the selection list column for the other table contains a null value. If there are matching rows between the tables, the entire result set row contains the data values of the base table. 3. Cross Join cross join returns all rows in the left table, with each row in the left table combined with all rows in the right table. Cross joins are also called Cartesian product. The table or view in the FROM clause can be specified in any order by an inner join or a full outer join, but the order of the table or view is important when you specify a table or view with a left or right outer join. For more information about using left or right outward joins to arrange tables, see Using outer joins. Example:-------------------------------------------------a table ID name B table ID job parent_id 1 Sheets 3 1 23 1 2 Li 42 34 2 3 Wang Wu 3 4 a.id with Parent_id existence Relationship--------------------------------------------------1) Internal connection Select a.*,b.* from a INNER join B on a.id=b.parent_id result is 1 3 1 23 1 2 Li 42 34 2 2) left connection select a.*,b.* from a ieft join B on a.id=b.parent_id result is 1 3 1 23 1 2 Li 42 34 2 3 Wang Wu null 3) Right connection Select a.*,b.* from a right join B on a.id=b.parent_id result is 1 3 1 23 1 2 Li 42 2 null 3 34 4 4) Fully connected Select a.*,b.* from a full join B on a.id=b.parent_id result is 1 3 1 23 1 2 Li 42 2 null 3 34 4 3 Wang Wu null
Four types of connections for SQL-left outer, right outer, internal, fully connected