Sie sind auf Seite 1von 5

JOINS

SQL joins with examples


JOINS
SQL Joins
BLL
JOINS
INNER JOIN The result consists of rows from T1 paired
with rows from T2.
LEFT OUTER JOIN The result consists of rows from T1 paired
with rows from T2 and, for each unpaired row
of T1, the concatenation of that row with the
null row of T2. All columns derived from T2
allow null values, regardless of whether the T2
column definitions allow nulls or not.
RIGHT OUTER JOIN The result consists of rows from T1 paired
with rows from T2 and, for each unpaired row
of T2, the concatenation of that row with the
null row of T1. All columns derived from T1
allow null values, regardless of whether the T1
column definitions allow nulls or not. ote that
T1 !"#$T %&T'! (%" T2 produces the
same result as T2 L')T %&T'! (%" T1*
thus, !"#$T %&T'! (%" is a redundant
feature.
FULL OUTER JOIN
+Availa,le, directl- onl- in .i. /i implements
using a &"% of left and right outer joins0
The result consists of rows from T1 paired
with rows from T2 and, for each unpaired row
of T1, the concatenation of that row with the
null row of T2, and, for each unpaired row of
T2, the concatenation of that row with the null
row of T1. All columns of the result allow null
values, whether the T1 and T2 column
definitions allow null values or not.
JOINS
Inner Join
The 1traditional1 wa- for coding an inner join +or 1natural join1 or 1e2ui3join104
The result contains onl- rows paired ,- the join condition A.5'6T% 7 8.9%!:5'6T.
"nner joins ma- still ,e coded in the 1traditional1 wa- under 582 ;<.1. $owever, the new join
s-ntax used for outer joins ma- also ,e used for inner joins. 'xample4
The 9$'!' clause is not re2uired, and is shown here onl- to illustrate that one can include
other predicates in addition to the join condition.
JOINS
Left Outer Join
The result consists of rows from the 5'6T paired with rows from '=6 and, for each unpaired
row of 5'6T, the concatenation of that row with the null row of '=6.
Right Outer Join
The result consists of rows from 5'6T paired with rows from '=6 and, for each unpaired row
of '=6, the concatenation of that row with the null row of 5'6T.
JOINS
Full Outer Join
The result consists of rows from 5'6T paired with rows from '=6 and, for each unpaired row
of 5'6T, the concatenation of that row with the null row of '=6 and, for each unpaired row of
'=6, the concatenation of that row with the null row of 5'6T.