Re: SQL question on an outer join

From: Pat <pat.casey_at_service-now.com>
Date: Fri, 9 May 2008 22:18:55 -0700 (PDT)
Message-ID: <707e48b1-f518-4d87-a6bd-92e2f82d3cdb@x35g2000hsb.googlegroups.com>


On May 9, 8:40 pm, fergus_v..._at_yahoo.com wrote:
> Hello,
> Learning SQL - will appreciate any help.
> Here is the case:
>
> Two tables with 0..n relationship
> TableA TableB
> ----------- --------------
> ColA ColB
> ColA_FK
> Col_C
>
> Data
> TableA.ColA
> ====================
> 1
> 2
>
> Table B
> ColB ColA_FK Col_C
> 11 2 12345
> 12 2 99999
>
> Resultset:
>
> --------------------------------------
> ColA ColB Col_C
> --------------------------------------
> 1 - -
> 2 12 99999
>
> In case no data exists in TableB for ColA=11, 1 from TableA shows up
> in result without any data from TableB
> However, in case of 2 from ColA, we want to record from TableB with
> Col_C = 99999
>
> I can do the outer join - however, how do I limit it so it picks only
> the row with 9999?
>
> Thanks in advance.
> Fergus

select tablea.cola, tableb.colb, tableb.colc from tablea left join tableb on tablea.cola = tableb.cola_fk where tableb.colc = 9999 Received on Sat May 10 2008 - 00:18:55 CDT

Original text of this message