[thelist] [sql] location of conditional

Paul Cowan evolt at funkwit.com
Mon Aug 4 22:01:56 CDT 2003



joshua wrote:
> It seems, though, that in an OUTER join the location of the conditional
> could make a big difference?  Wrong?  Right?

oh my yes.

SELECT
	*
FROM
	A
LEFT JOIN B ON
	(A.Foo = B.Foo)
AND	(B.Shoesize = 9)

and

{ ... }
LEFT JOIN B ON
	(A.Foo = B.Foo)
WHERE
	(B.Shoesize = 9)

will give you totally different results. Given the following data:

Table A		Table B
Foo		Foo	Shoesize
1		1	9
2		2	10
3


The first query will return
	1	1	9
	2	null	null

but the second will only return
	1	1	9

Paul


More information about the thelist mailing list