Scenario 1: Fetch data from two or more tables.
select * from table1 a ,table2 b where a.id=b.id (this way of writing is not readable, and it is not easy to read the association condition and the filter condition of the statement)
select * from table1 a join table2 b using (id); (the join conditions between tables are separated from the filter conditions of table records, which is more readable)
Scenario 2: Regardless of whether Table 1 can be associated with Table 2 (regardless of whether the department recruits people or not), display Table 1 (display all departments).
select * from emp a right join dept b using (deptno);
Induction: left, right are to indicate the position of the main table. The (+) sign is placed after the appendix table.
Peer-to-peer joins (only displayed on associations) | join | a.id=b.id |
Left association (the left table is the main table) | left join | a.id=b.id(+) |
Right association (right table main table) | right join | a.id(+)=b.id |
Full association (both displayed) | full join |