|
 |
asp_databases thread: SQL Join reference?
Message #1 by "Cory Koski" <ckoski@w...> on Tue, 13 Jun 2000 10:57:25 -0400
|
|
I'm looking for a reference that nicely explains the different kinds of
joins, including Inner and Outer, left inner, left outer, etc. etc. Does
anyone know of one in particular?
Cory
Message #2 by "Ken Schaefer" <ken.s@a...> on Wed, 14 Jun 2000 15:41:57 +1000
|
|
Inner Join produces a table which contains only those records from both
tables where the values in the joined upon column match - this is the usual
join that you do:
SELECT table1.field1, table2.field1
FROM table1, table2
WHERE table1.field1 = table2.field1
OR
SELECT table1.field1, table2.field1
FROM table1
INNER JOIN table2
ON table1.field1 = table2.field1
Outer Joins can be Left Outer Joins, Right Outer Joins, or Full Outer Joins.
An outer join finds all those records that an inner join does, plus records
from either the left, right, or both tables that do not have matches in the
joined upon column.
eg
SELECT table1.field1, table2.field1
FROM table1
LEFT JOIN table2
ON table1.field1 = table2.field1
would select all records from Table1, and only those records from Table2
where, in table2.field1 there was a corresponding value in table1.field1.
For those records in table1.field1 where there is no matching value in
table2.field1, the table2 column is filled with NULLs.
The reverse happens with Right Joins (table1 and table2 are juxtaposed).
Outer Joins find all records in all tables that are joined, subject to any
WHERE clause.
HTH
Cheers
Ken
----- Original Message -----
From: "Cory Koski"
To: "ASP Databases" <asp_databases@p...>
Sent: Wednesday, June 14, 2000 12:57 AM
Subject: [asp_databases] SQL Join reference?
> I'm looking for a reference that nicely explains the different kinds of
> joins, including Inner and Outer, left inner, left outer, etc. etc. Does
> anyone know of one in particular?
>
> Cory
Message #3 by "Cory Koski" <ckoski@w...> on Wed, 14 Jun 2000 09:07:15 -0400
|
|
thanks... wow... didn't expect that, but that's great! Thanks Ken!
----- Original Message -----
From: "Ken Schaefer"
To: "ASP Databases" <asp_databases@p...>
Sent: Wednesday, June 14, 2000 1:41 AM
Subject: [asp_databases] Re: SQL Join reference?
|
|
 |