Subject Re: [firebird-support] What's wrong with this query?
Author Mark Rotteveel
Svein Erling Tysvaer wrote:
> Sorry, I didn't notice the last few replies to this thread where it is
> better described what you want (my reply was directed towards your
> initial email only, where it still wasn't evident what you were looking
> for). Emb_blaster has already written an appropriate query, and Mark
> almost got it right as well, the only thing missing is that the
> parameter has to be in the JOIN clause:

The position of that condition is more a matter of 'taste' and maybe of
optimization (I am not sure how the optimizer of Firebird handles this),
the end result of my query and the version below should be the same
(although the execution time may differ). However semantically, the ON
condition should only contain the columns used for the join, not any
'other' select-conditions.

> SELECT te.email_address
> FROM temp_email3 te
> LEFT JOIN recipient re ON te.email_address = re.email_address
> AND re.fk_client_id = :A_CLIENT_ID
> WHERE re.email_address IS NULL
>
> Basically, you have two identically good solutions to choose from.

--
Mark Rotteveel <Avalanche1979@...>