Re: SQL Syntax
- From: "S Shulman" <smshulman@xxxxxxxxxxx>
- Date: Mon, 29 Aug 2005 12:33:56 +0100
Thanks for your help,
I am coding SQL statements for some time but I never came across an in depth
SQL language book, please let me know if you know of one
Shmuel
"Adam Machanic" <amachanic@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23Y3A$7CrFHA.904@xxxxxxxxxxxxxxxxxxxxxxx
> You're close as is. Try:
>
> SELECT
> TableA.FieldA,
> TableB.FieldA
> FROM TableA
> LEFT OUTER JOIN TableB ON TableA.PK = TableB.PK
> AND TableB.FieldX = xyz
>
>
> Note that you'll have to replace 'PK' with the actual primary key. Also
> note that I've put the condition into the ON clause. When working with
> OUTER JOINs, it's important to remember that any condition in the ON
> clause
> of the LEFT OUTER JOIN will be logically treated as part of the join, and
> if
> it evaluates to false will cause the columns for that table to return NULL
> for any row in the 'left' table. If that same condition was in the WHERE
> clause, it would be logically evaluated AFTER the JOIN -- and therefore
> would filter the final result set, and, in this case, produce a result set
> that would be equivalent to that produced by an INNER JOIN. You should
> play
> with this a bit, if you have time, and get a feel for what I'm talking
> about.
>
> Let me know if you have any further questions.
>
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.datamanipulation.net
> --
>
>
> "S Shulman" <smshulman@xxxxxxxxxxx> wrote in message
> news:uxFS5OCrFHA.2996@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi
>>
>> I want to get records fron the db based on the following criteria:
>> TableA.FieldA, TableB.FieldA FROM TableA
>> LEFT OUTER JOIN TableB etc.
>> WHERE (TableB.FieldX =xyz or in case there in no records in TableB so
> these
>> fieldswill be Null)
>>
>> Is there any way to achieve that?
>> Thank you in advance,
>> Shmuel Shulman
>>
>>
>
>
.
- Follow-Ups:
- Re: SQL Syntax
- From: Adam Machanic
- Re: SQL Syntax
- References:
- SQL Syntax
- From: S Shulman
- Re: SQL Syntax
- From: Adam Machanic
- SQL Syntax
- Prev by Date: Re: SQL Syntax
- Next by Date: Re: SQL Syntax
- Previous by thread: Re: SQL Syntax
- Next by thread: Re: SQL Syntax
- Index(es):
Relevant Pages
|