[thelist] sql: LEFT JOIN and WHERE clause trouble

Ken Schaefer ken at adOpenStatic.com
Thu Aug 14 03:04:29 CDT 2003


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Chris W. Parker" <cparker at swatgear.com>
Subject: RE: [thelist] sql: LEFT JOIN and WHERE clause trouble


: Thanks Paul and Ken, your solution worked perfectly.
: (Now I just need to understand why!)
:
: Chris.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I think Paul explained that...

:-)

With the WHERE clause you are restricting the set on the right-hand side of
the JOIN, i.e. you are joining the first table to a "subset of the second
table", and this "subset of the second table" only includes records where
pmed=0

Think of the query as applying the WHERE clause *before* it does the JOIN of
the two tables together.

Cheers
Ken



More information about the thelist mailing list