Re: SQL Query - Help with Joins
- From: CRPence <crpence@xxxxxxxxxxxx>
- Date: Tue, 26 Jun 2007 01:21:29 -0500
Just for awareness, to make the WHERE clause function for some future query that might require it, something like *either* of the following replacement for the ANDed tests [or similar logic] would be required in the WHERE clause:
IFNULL(budget.month, 'june') = 'june'
AND IFNULL(budget.year , 2007 ) = 2007
( budget.month = 'june' OR budget.month IS NULL )
AND ( budget.year = 2007 OR budget.year IS NULL )
The selection in the first query below, prevents the NULL generated rows from being included; the row will be generated by the join, but will be excluded by the WHERE selection because a comparison test is _not true_ for the NULL value. When the selection is applied in the join selection as in the second query below, that same exclusion does not occur because the row is still generated by the join [but there is no selection in the WHERE clause to exclude].
Regards, Chuck
-- All comments provided "as is" with no warranties of any kind whatsoever and may not represent positions, strategies, nor views of my employer
travo wrote:
Ah, I nailed it. Rather than;.
LEFT OUTER JOIN
budget ON
budget.sales guy = sales.sales guy
AND
budget.product group = SUBSTRING(sales.product group,1,3)
WHERE
1 = 1
AND budget.month = june
AND budget.year = 2007
I needed to include those clauses in the join;
LEFT OUTER JOIN
budget ON
budget.sales guy = sales.sales guy
AND budget.product group = SUBSTRING(sales.product group,1,3)
AND budget.month = june
AND budget.year = 2007
My nulls have appeared. Sweet!
Chuck, thanks!
Travis
- Follow-Ups:
- Re: SQL Query - Help with Joins
- From: Jonathan Ball
- Re: SQL Query - Help with Joins
- References:
- SQL Query - Help with Joins
- From: travo
- Re: SQL Query - Help with Joins
- From: CRPence
- Re: SQL Query - Help with Joins
- From: travo
- Re: SQL Query - Help with Joins
- From: travo
- SQL Query - Help with Joins
- Prev by Date: Re: SQL Query - Help with Joins
- Next by Date: Re: SRC A600 5010 when trying to install LIC on new i520
- Previous by thread: Re: SQL Query - Help with Joins
- Next by thread: Re: SQL Query - Help with Joins
- Index(es):
Relevant Pages
|