Author: Garrett Fitzgerald
Posted: 2019-04-02 17:05:09 Link
Hey, all. I had a general SQL question. Often, I find myself needing to use
the syntax:
FROM a
LEFT JOIN b ON a.key = b.key AND b.field = 'Value'
because if I filter b.field in the WHERE clause, I've effectively made the
LEFT JOIN an inner one.
That makes me wonder, at what point do we stop moving conditions to the
JOIN clause? Obviously, some can't move for syntactical reasons, such as
subqueries. But short of that, when does it make sense to limit a non-outer
join in the join criteria? Never?
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAGd8Mrc_OLPhNMoXcZCT70zvDh0bhA5zZM+4WU=qS-yS3yLCNg@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Charlie-gm
Posted: 2019-04-02 17:22:12 Link
My experience has shown either syntax (WHERE vs INNER JOIN) to provide
the same result without noticeable performance difference.
I think the INNER JOIN syntax was added later in the SQL standards.
If you solely use JOIN statements, one could argue the readability is
better (aka more explicit). Other than that, perhaps a particular DBMS
would "optimize better" with INNER JOIN or WHERE - but I kind of doubt it.
-Charlie
On 4/2/2019 6:05 PM, Garrett Fitzgerald wrote:
> Hey, all. I had a general SQL question. Often, I find myself needing to use
> the syntax:
>
> FROM a
> LEFT JOIN b ON a.key = b.key AND b.field = 'Value'
>
> because if I filter b.field in the WHERE clause, I've effectively made the
> LEFT JOIN an inner one.
>
> That makes me wonder, at what point do we stop moving conditions to the
> JOIN clause? Obviously, some can't move for syntactical reasons, such as
> subqueries. But short of that, when does it make sense to limit a non-outer
> join in the join criteria? Never?
>
>
> --- StripMime Report -- processed MIME parts ---
> multipart/alternative
> text/plain (text body -- kept)
> text/html
> ---
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/04dee286-83bf-041c-1e02-61f12034542a@gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Eric Selje
Posted: 2019-04-03 15:35:08 Link
Just be aware that VFP's SQL lets you get away with that, but not all
incarnations of SQL will.
Eric
On Tue, Apr 2, 2019 at 5:22 PM Charlie-gm <ccbibleman@gmail.com> wrote:
>
> My experience has shown either syntax (WHERE vs INNER JOIN) to provide
> the same result without noticeable performance difference.
>
> I think the INNER JOIN syntax was added later in the SQL standards.
>
> If you solely use JOIN statements, one could argue the readability is
> better (aka more explicit). Other than that, perhaps a particular DBMS
> would "optimize better" with INNER JOIN or WHERE - but I kind of doubt it.
>
> -Charlie
>
>
> On 4/2/2019 6:05 PM, Garrett Fitzgerald wrote:
> > Hey, all. I had a general SQL question. Often, I find myself needing to
> use
> > the syntax:
> >
> > FROM a
> > LEFT JOIN b ON a.key = b.key AND b.field = 'Value'
> >
> > because if I filter b.field in the WHERE clause, I've effectively made
> the
> > LEFT JOIN an inner one.
> >
> > That makes me wonder, at what point do we stop moving conditions to the
> > JOIN clause? Obviously, some can't move for syntactical reasons, such as
> > subqueries. But short of that, when does it make sense to limit a
> non-outer
> > join in the join criteria? Never?
> >
> >
> > --- StripMime Report -- processed MIME parts ---
> > multipart/alternative
> > text/plain (text body -- kept)
> > text/html
> > ---
> >
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAAwxvUmMjkgKO2f-ESfQ2L37muthi7pnTqc9bYvCt3k_i=Y3Jg@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Charlie-gm
Posted: 2019-04-03 15:55:28 Link
Hey Eric,
What do you mean? I have not run into a SQL DBMS that does not support
both WHERE and INNER JOIN.
-Charlie
On 4/3/2019 4:35 PM, Eric Selje wrote:
> Just be aware that VFP's SQL lets you get away with that, but not all
> incarnations of SQL will.
>
> Eric
>
>
> On Tue, Apr 2, 2019 at 5:22 PM Charlie-gm <ccbibleman@gmail.com> wrote:
>
>> My experience has shown either syntax (WHERE vs INNER JOIN) to provide
>> the same result without noticeable performance difference.
>>
>> I think the INNER JOIN syntax was added later in the SQL standards.
>>
>> If you solely use JOIN statements, one could argue the readability is
>> better (aka more explicit). Other than that, perhaps a particular DBMS
>> would "optimize better" with INNER JOIN or WHERE - but I kind of doubt it.
>>
>> -Charlie
>>
>>
>> On 4/2/2019 6:05 PM, Garrett Fitzgerald wrote:
>>> Hey, all. I had a general SQL question. Often, I find myself needing to
>> use
>>> the syntax:
>>>
>>> FROM a
>>> LEFT JOIN b ON a.key = b.key AND b.field = 'Value'
>>>
>>> because if I filter b.field in the WHERE clause, I've effectively made
>> the
>>> LEFT JOIN an inner one.
>>>
>>> That makes me wonder, at what point do we stop moving conditions to the
>>> JOIN clause? Obviously, some can't move for syntactical reasons, such as
>>> subqueries. But short of that, when does it make sense to limit a
>> non-outer
>>> join in the join criteria? Never?
>>>
>>>
>>> --- StripMime Report -- processed MIME parts ---
>>> multipart/alternative
>>> text/plain (text body -- kept)
>>> text/html
>>> ---
>>>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/f30c2fa7-1067-ebf1-b9c6-5a3b592bbfc0@gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Eric Selje
Posted: 2019-04-03 16:32:36 Link
I don't remember specifically, but when you run into it and start
scratching your head wondering why you're getting a syntax error - you'll
know! :)
On Wed, Apr 3, 2019 at 3:55 PM Charlie-gm <ccbibleman@gmail.com> wrote:
>
> Hey Eric,
>
> What do you mean? I have not run into a SQL DBMS that does not support
> both WHERE and INNER JOIN.
>
> -Charlie
>
>
> On 4/3/2019 4:35 PM, Eric Selje wrote:
> > Just be aware that VFP's SQL lets you get away with that, but not all
> > incarnations of SQL will.
> >
> > Eric
> >
> >
> > On Tue, Apr 2, 2019 at 5:22 PM Charlie-gm <ccbibleman@gmail.com> wrote:
> >
> >> My experience has shown either syntax (WHERE vs INNER JOIN) to provide
> >> the same result without noticeable performance difference.
> >>
> >> I think the INNER JOIN syntax was added later in the SQL standards.
> >>
> >> If you solely use JOIN statements, one could argue the readability is
> >> better (aka more explicit). Other than that, perhaps a particular DBMS
> >> would "optimize better" with INNER JOIN or WHERE - but I kind of doubt
> it.
> >>
> >> -Charlie
> >>
> >>
> >> On 4/2/2019 6:05 PM, Garrett Fitzgerald wrote:
> >>> Hey, all. I had a general SQL question. Often, I find myself needing to
> >> use
> >>> the syntax:
> >>>
> >>> FROM a
> >>> LEFT JOIN b ON a.key = b.key AND b.field = 'Value'
> >>>
> >>> because if I filter b.field in the WHERE clause, I've effectively made
> >> the
> >>> LEFT JOIN an inner one.
> >>>
> >>> That makes me wonder, at what point do we stop moving conditions to the
> >>> JOIN clause? Obviously, some can't move for syntactical reasons, such
> as
> >>> subqueries. But short of that, when does it make sense to limit a
> >> non-outer
> >>> join in the join criteria? Never?
> >>>
> >>>
> >>> --- StripMime Report -- processed MIME parts ---
> >>> multipart/alternative
> >>> text/plain (text body -- kept)
> >>> text/html
> >>> ---
> >>>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAAwxvU=Epc6aQD3YbUOTumAZKVs72Z2-5CYvAHQpvjm3MAWUHQ@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Eric Selje
Posted: 2019-04-03 16:34:51 Link
This StackOverflow question seems to sum it up:
On Wed, Apr 3, 2019 at 4:32 PM Eric Selje <Eric@saltydogllc.com> wrote:
> I don't remember specifically, but when you run into it and start
> scratching your head wondering why you're getting a syntax error - you'll
> know! :)
>
> On Wed, Apr 3, 2019 at 3:55 PM Charlie-gm <ccbibleman@gmail.com> wrote:
>
>>
>> Hey Eric,
>>
>> What do you mean? I have not run into a SQL DBMS that does not support
>> both WHERE and INNER JOIN.
>>
>> -Charlie
>>
>>
>> On 4/3/2019 4:35 PM, Eric Selje wrote:
>> > Just be aware that VFP's SQL lets you get away with that, but not all
>> > incarnations of SQL will.
>> >
>> > Eric
>> >
>> >
>> > On Tue, Apr 2, 2019 at 5:22 PM Charlie-gm <ccbibleman@gmail.com> wrote:
>> >
>> >> My experience has shown either syntax (WHERE vs INNER JOIN) to provide
>> >> the same result without noticeable performance difference.
>> >>
>> >> I think the INNER JOIN syntax was added later in the SQL standards.
>> >>
>> >> If you solely use JOIN statements, one could argue the readability is
>> >> better (aka more explicit). Other than that, perhaps a particular DBMS
>> >> would "optimize better" with INNER JOIN or WHERE - but I kind of doubt
>> it.
>> >>
>> >> -Charlie
>> >>
>> >>
>> >> On 4/2/2019 6:05 PM, Garrett Fitzgerald wrote:
>> >>> Hey, all. I had a general SQL question. Often, I find myself needing
>> to
>> >> use
>> >>> the syntax:
>> >>>
>> >>> FROM a
>> >>> LEFT JOIN b ON a.key = b.key AND b.field = 'Value'
>> >>>
>> >>> because if I filter b.field in the WHERE clause, I've effectively made
>> >> the
>> >>> LEFT JOIN an inner one.
>> >>>
>> >>> That makes me wonder, at what point do we stop moving conditions to
>> the
>> >>> JOIN clause? Obviously, some can't move for syntactical reasons, such
>> as
>> >>> subqueries. But short of that, when does it make sense to limit a
>> >> non-outer
>> >>> join in the join criteria? Never?
>> >>>
>> >>>
>> >>> --- StripMime Report -- processed MIME parts ---
>> >>> multipart/alternative
>> >>> text/plain (text body -- kept)
>> >>> text/html
>> >>> ---
>> >>>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAAwxvUkOzE7bAKsC98-puqToEprOmuQ210n514VNkUx8NBPMjA@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Charlie Coleman
Posted: 2019-04-03 16:46:34 Link
OK, so we're back to it does not yield a different result (nor an error),
but in regards to readability using INNER JOIN is more clear. But we should
add that INNER JOIN is the more modern standard of use. One of the
responses on Stack Overflow mentions "accidental cross-joins" but I have
not experienced that even with my most complicated "WHERE" clauses (of
course, like all my code, I sometimes do not get the statement correct on
the first try, but that can happen with my "JOINS" as well as my "WHERES"
<g>).
-Charlie
On Wed, Apr 3, 2019 at 5:35 PM Eric Selje <Eric@saltydogllc.com> wrote:
> This StackOverflow question seems to sum it up:
>
>
>
>
> On Wed, Apr 3, 2019 at 4:32 PM Eric Selje <Eric@saltydogllc.com> wrote:
>
> > I don't remember specifically, but when you run into it and start
> > scratching your head wondering why you're getting a syntax error - you'll
> > know! :)
> >
> > On Wed, Apr 3, 2019 at 3:55 PM Charlie-gm <ccbibleman@gmail.com> wrote:
> >
> >>
> >> Hey Eric,
> >>
> >> What do you mean? I have not run into a SQL DBMS that does not support
> >> both WHERE and INNER JOIN.
> >>
> >> -Charlie
> >>
> >>
> >> On 4/3/2019 4:35 PM, Eric Selje wrote:
> >> > Just be aware that VFP's SQL lets you get away with that, but not all
> >> > incarnations of SQL will.
> >> >
> >> > Eric
> >> >
> >> >
> >> > On Tue, Apr 2, 2019 at 5:22 PM Charlie-gm <ccbibleman@gmail.com>
> wrote:
> >> >
> >> >> My experience has shown either syntax (WHERE vs INNER JOIN) to
> provide
> >> >> the same result without noticeable performance difference.
> >> >>
> >> >> I think the INNER JOIN syntax was added later in the SQL standards.
> >> >>
> >> >> If you solely use JOIN statements, one could argue the readability is
> >> >> better (aka more explicit). Other than that, perhaps a particular
> DBMS
> >> >> would "optimize better" with INNER JOIN or WHERE - but I kind of
> doubt
> >> it.
> >> >>
> >> >> -Charlie
> >> >>
> >> >>
> >> >> On 4/2/2019 6:05 PM, Garrett Fitzgerald wrote:
> >> >>> Hey, all. I had a general SQL question. Often, I find myself needing
> >> to
> >> >> use
> >> >>> the syntax:
> >> >>>
> >> >>> FROM a
> >> >>> LEFT JOIN b ON a.key = b.key AND b.field = 'Value'
> >> >>>
> >> >>> because if I filter b.field in the WHERE clause, I've effectively
> made
> >> >> the
> >> >>> LEFT JOIN an inner one.
> >> >>>
> >> >>> That makes me wonder, at what point do we stop moving conditions to
> >> the
> >> >>> JOIN clause? Obviously, some can't move for syntactical reasons,
> such
> >> as
> >> >>> subqueries. But short of that, when does it make sense to limit a
> >> >> non-outer
> >> >>> join in the join criteria? Never?
> >> >>>
> >> >>>
> >> >>> --- StripMime Report -- processed MIME parts ---
> >> >>> multipart/alternative
> >> >>> text/plain (text body -- kept)
> >> >>> text/html
> >> >>> ---
> >> >>>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAJGvLx0FyLGM_mMd17SCJ5Zm-MVZ2Xk1rgEu0_G_VAO00XM2Ag@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Frank Cazabon
Posted: 2019-04-04 07:53:22 Link
Garrett,
> LEFT JOIN b ON a.key = b.key*AND b.field = 'Value'*
is it the conditions/filters (AND b.field = 'Value') that you are asking
about, not the difference between WHERE and JOIN?
If so, then this might help:
https://stackoverflow.com/questions/10517225/filtering-joins-where-vs-on
or this:
https://stackoverflow.com/questions/10297231/where-clause-vs-on-when-using-join
Frank.
Frank Cazabon
On 02/04/2019 06:05 PM, Garrett Fitzgerald wrote:
> Hey, all. I had a general SQL question. Often, I find myself needing to use
> the syntax:
>
> FROM a
> LEFT JOIN b ON a.key = b.key AND b.field = 'Value'
>
> because if I filter b.field in the WHERE clause, I've effectively made the
> LEFT JOIN an inner one.
>
> That makes me wonder, at what point do we stop moving conditions to the
> JOIN clause? Obviously, some can't move for syntactical reasons, such as
> subqueries. But short of that, when does it make sense to limit a non-outer
> join in the join criteria? Never?
>
>
> --- StripMime Report -- processed MIME parts ---
> multipart/alternative
> text/plain (text body -- kept)
> text/html
> ---
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/890d3fb4-5186-3006-d40c-9e188c6846e5@gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.