Subject Re: [firebird-support] SQL help please
Author Gary Benade
hb>
>Stylistically the second one is correct, although logically both achieve
>the same thing.
>Make it a habit to properly separate join criteria from search criteria,
>though. Some class interfaces, particularly those that do magic with
>replaceable parameters, have trouble parsing statements that jumble up
>static syntax elements with dynamic ones...clean code habits tend to make
>our work self-documenting, too.
ab>
>The advantage of this is that the optimizer can calculate in which order
>the
> tables should be joined.
set>
>To me, both seems meaningless, but should give the same result.
ad>
>does the first one work at all? I would never have thought it to be valid
>query syntax.

Thanks for all your replies. I think my initial example was a bit confusing
so I have taken a real example from my project and stripped it down to bare
bones.

This query should return all the bulk rows joined with backstocklevels for a
certain date if any exist.

select *
from
bulk b
left outer join backstocklevels bs on (b.link = bs.itemlink and bs.zdate =
'01-dec-2004')

correctly returns 11 rows

select *
from
bulk b
left outer join backstocklevels bs on (b.link = bs.itemlink)
where bs.zdate = '01-dec-2004'

returns no rows

I would normally have used the second query without a second thought but the
client pointed out that the reports don't add up, hence the first query. Is
their another way of coding this that is stylistically correct and wont
confuse the optimiser and 3rd party tools. I have a sneaky feeling I am
missing something blindingly obvious here....

Thanks again, in advance
Gary