Re: Multiple Select Statements
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Sun, 17 May 2009 09:41:40 -0700
(rich.ai@xxxxxxxxxxxxx) writes:
Works like a charm, many thanks all. I'm going to have to some reading
on this full outer join.
How would I modify the Query to include a 3 more dervied tables X3,X4
& X5 as I'm not sure what the ON 1=1 means. Most probably will become
clear once I've done some reading
The "ON 1 = 1" transforms the outer join to a cross join, but with the added
twist that you will always get at least one row, even if any of the queries
return no rows.
I'm afraid that doing some reading may not be sufficient to understand the
resulting query. It's still a very odd and most likely incorrect query.
The main usage for full outer joins is when comparing two data sets that
ideally should be identical for differences. While one-way outer joins
are common, full joins are far less so, and five-join full joins even
lesser. I have found that even as an experienced SQL programmer, it's
easy to get lost when dealing with full joins.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- Follow-Ups:
- Re: Multiple Select Statements
- From: rich . ai
- Re: Multiple Select Statements
- References:
- Multiple Select Statements
- From: rich . ai
- Re: Multiple Select Statements
- From: Plamen Ratchev
- Re: Multiple Select Statements
- From: rich . ai
- Multiple Select Statements
- Prev by Date: Re: Exit a proc from SQL Server Management Studio
- Next by Date: Re: Exit a proc from SQL Server Management Studio
- Previous by thread: Re: Multiple Select Statements
- Next by thread: Re: Multiple Select Statements
- Index(es):
Relevant Pages
|