Re: A newbie question on SQL...

From: Bob Swisshelm <swisshelm_at_lilly.com>
Date: 16 Feb 95 07:07:06 EST
Message-ID: <1995Feb16.070706.3997_at_inet.d48.lilly.com>


In article <3hrjv7$p16_at_amdint.amd.com> Chung Ley, chung.ley_at_amd.com writes:
> My query looks like this:
>
> select a.column1, a.column2, b.column1, b.column2,
> c.full_name
> from TableA a, TableB b, TableC c
> where a.key1 (+)= b.key1
> and a.key2 (+)= b.key2
> and b.latest_flag = 'Y'
> and b.userid = c.userid;
>
>Well, it didn't work like I expected.... It basically gives
>back results only when there is matching keys in TableA and
>TableB. I would like me to give me null values for b.column1,
>b.column2 and c.full_name if there is no matching records in
>TableB...

Looks to me like you put the + on the wrong side. It's easy to get confused. I had someone explain it to me like this...Put the + on the side that can have null values.

If there is a possibility that you won't have a C record for a B record, you will also want to put a + after c.userid.

Hope this works for you.

Bob Swisshelm                | swisshelm_at_Lilly.com     | 317 276 5472
Eli Lilly and Company        | Lilly Corporate Center  | Indianapolis, 
IN 46285 Received on Thu Feb 16 1995 - 13:07:06 CET

Original text of this message