join usage

Even the case of using the table join, is defective inner join, left join used in the development and right join belong outer join, outer join further comprising a full join

an existing two tables, Table A is a table on the left. Table B is a table on the right. Which have four records, two records which is the same name:

Results AB is produced 1.INNER JOIN intersection

the SELECT * the FROM TableA the INNER TableA.name the JOIN TableB the ON = TableB.name

2.LEFT [OUTER] generated the JOIN a complete set of tables, and the table B is matched with a value of substituted places no matching value of null.
* The FROM TableA the LEFT OUTER the SELECT TableB the ON TableA.name the JOIN = TableB.name

3.RIGHT [OUTER] generated the JOIN complete set of Table B, and Table A has a value in the match, substituted places no matching value of null.

SELECT * FROM TableA RIGHT OUTER JOIN TableB ON TableA.name = TableB.name
icon as left join similar.

4.FULL [OUTER] JOIN A and B, and generating sets. For the record does not match, it will order as null values.
SELECT * FROM TableA.name = TableA FULL OUTER JOIN TableB ON TableB.name
value is NULL can not match the find out:
* The FROM FULL OUTER TableA the SELECT TableB the ON TableA.name the JOIN = TableB.name
the WHERE TableA.id the IS OR TableB.id the IS null null

data 5. CROSS JOIN Tables A and B is a combination of N * M, i.e. flute Carl product . As Regular produce 4 * 4 = 16 records, in the development process, we are sure that the data to be filtered, so this is rarely used.
SELECT * FROM TableA CROSS JOIN TableB

Guess you like

Origin www.cnblogs.com/ling518/p/11320000.html