Simply and clearly, connect to the inner and outer links.
Suppose there are two tables of A and B
Internal connection: Inner JOIN indicates that the record of the AB table is displayed, excluding the condition of the AB table .
There are three kinds of outer joins, that is, left OUTER joins, right connection, OUTER join, full OUTER join, the following is a simple parse. 1.A Left OUTER JOIN B indicates that the records of table A are displayed, and the result set that matches the condition of table B is displayed, and the null representation of the condition is not met. 2.A Right OUTER JOIN B indicates that the records of table B are displayed, showing the result set that matches the condition of table A, and non-conforming null representation. 3.A Full OUTER JOIN B indicates that the records of table A and B are displayed, and the non-qualifying null representation.
Instance:
[[email protected]] Sql>select * from A;
Number Name
---- ----------
1000 Sheets of three
2000 John Doe
3000 Harry
[[email protected]] Sql>select * from B;
Numbered items
---- ----------
1000 TV
2000 VCR
4000 Bicycles
[[email protected]] Sql>set NULL nulls-This is where I define NULL as a "null value" for display aspects.
[[email protected]] Sql>select a.*,b.* from a inner join B on a. Number =b. number;
Number Name Number product
---- ---------- ---- ----------
1000 31,000 TVs
2000 Li 42,000 VCR
[[email protected]] Sql>select a.*,b.* from a LEFT join B on a. Number =b. number;
Number Name Number product
---- ---------- ---- ----------
1000 31,000 TVs
2000 Li 42,000 VCR
3000 Wang value NULL
[[email protected]] Sql>select a.*,b.* from a right join B on a. Number =b. number;
Number Name Number product
---- ---------- ---- ----------
1000 31,000 TVs
2000 Li 42,000 VCR
NULL NULL value 4000 bike
[[email protected]] Sql>select a.*,b.* from a full join B on a. Number =b. number;
Number Name Number product
---- ---------- ---- ----------
1000 31,000 TVs
2000 Li 42,000 VCR
3000 Wang value NULL
NULL NULL value 4000 bike
---
。
The difference between a inner join, a left JOIN, a right join, and a full join in an SQL statement