Reprint Address: http://www.phpddt.com/db/inner_join-outer-join.html respect for the work of others is to respect their own achievements!
The difference between inner join, outer join, and Cross join in SQL many people do not know, I also ask, just look for information to look at, with their previous understanding, if you use join table, the case of defects is inner join, in addition, The LEFT join and right join used in the development belong to the outer join, and the outer join also includes the full join. Below I let you know the difference by the icon.
There are two tables, table A is the one on the left. Table B is the list on the right. Each of them has four records, of which two records have the same name:
The result of the 1.INNER JOIN is the intersection of AB
SELECT * from TableA INNER JOIN TableB on tablea.name = Tableb.name
A 2.LEFT [OUTER] JOIN produces a full set of table A, whereas a match in B table has a value, and no match is substituted with a null value.
SELECT * from TableA left OUTER joins TableB on tablea.name = Tableb.name
A 3.RIGHT [OUTER] JOIN produces a full set of Table B, and a match in table A has a value, and no match is substituted with a null value.
SELECT * from TableA right OUTER JOIN TableB on tablea.name = Tableb.name
Icons are similar to the left join.
The 4.FULL [OUTER] JOIN produces a and B's set. For records that do not have a match, NULL is the value.
SELECT * from TableA full OUTER JOIN TableB on tablea.name = Tableb.name
You can find the value without matching by the IS null:
SELECT * from TableA full OUTER JOIN TableB on tablea.name = Tableb.name
WHERE tablea.id is null OR tableb.id is null
5. Cross joins a n*m combination of the data from table A and table B, the Cartesian product. If this regular session produces 4*4=16 records, we must filter the data during the development process, so this is seldom used.
SELECT * from TableA cross JOIN TableB
We believe that the difference between inner join, outer join and Cross join is at a glance.
Differences between inner JOIN, outer join, and Cross join in SQL