Re: JOIN on multiple conditions
From: Joe Celko (jcelko212_at_earthlink.net)
Date: 11/22/04
- Next message: Scott Ivey: "Re: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied."
- Previous message: Aaron [SQL Server MVP]: "Re: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied."
- In reply to: Hugo Kornelis: "Re: JOIN on multiple conditions"
- Next in thread: Hugo Kornelis: "Re: JOIN on multiple conditions"
- Reply: Hugo Kornelis: "Re: JOIN on multiple conditions"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 22 Nov 2004 08:03:48 -0800
>> [OUTER UNION] I only have experience with SQL Server, and I don't
think such an operation is implemented (at least not in SQL Server
2000). What is it supposed to do? <<
Let TN be the table that you get from an INNER join. Let TN1 be the
table you get from padding the rows of the first table that were left
out of the INNER JOIN with NULLs. Let TN2 be the table you get from
padding the rows of the second table that were left out of the INNER
JOIN with NULLs.
Now define the infixed JOINs in terms of UNION ALL operations on those
tables:
a) LEFT OUTER JOIN
SELECT * FROM TN
UNION ALL
SELECT * FROM XN1
b) RIGHT OUTER JOIN
SELECT * FROM TN
UNION ALL
SELECT * FROM XN2
c) FULL OUTER JOIN
SELECT * FROM TN
UNION ALL
SELECT * FROM XN1
UNION ALL
SELECT * FROM XN2
d) UNION JOIN
SELECT * FROM XN1
UNION ALL
SELECT * FROM XN2
A UNION JOIN is a FULL OUTER JOIN with the jam filling in the middle
removed :). The SAS statistical package has it, but I don't know if
anyone bothered to implement it.
--CELKO--
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are. Sample data is also a good idea, along with clear
specifications.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
- Next message: Scott Ivey: "Re: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied."
- Previous message: Aaron [SQL Server MVP]: "Re: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied."
- In reply to: Hugo Kornelis: "Re: JOIN on multiple conditions"
- Next in thread: Hugo Kornelis: "Re: JOIN on multiple conditions"
- Reply: Hugo Kornelis: "Re: JOIN on multiple conditions"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|