Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Selecting from joined tables (simple question)

Re: Selecting from joined tables (simple question)

From: Eric Parker <eric.parkerthedross_at_virgin.net>
Date: Thu, 29 Jan 2004 14:25:11 -0000
Message-ID: <fJ8Sb.13260$YV1.7006@newsfep4-winn.server.ntli.net>

"willy gates" <willy_gates_at_hotmail.com> wrote in message news:4344f587.0401290317.3de963b3_at_posting.google.com...
> Thanks for help with this one
>
> I have 2 tables
>
> DATA_STANDARD with columns ID and VALUE
>
> and
>
> DATA_EXTRA with column DS_ID and EXTRA_VALUE
>
> The idea is that extra information is stored in the DATA_EXTRA table
> when required.
>
> How do I select all values from DATA_STANDARD where there is either no
> entry in DATA_EXTRA or EXTRA_VALUE is zero.
>
> something like this?
>
> select ds.id from DATA_STANDARD ds, DATA_EXTRA de
> where
> ( ds.id not in ( select DS_ID from DATA_EXTRA ) )
> or
> (
> --Join
> ( ds.id = de.DS_ID )
> and
> ( de.extra_value is null )
> )
>
> Why is this wrong?
>
> Thanks

willy gates

I'm not sure whether your looking for 0 or null in de.extra_value. You may be looking for union rather than or.

This may be a solution :

select ds.id from DATA_STANDARD ds
where
( ds.id not in ( select DS_ID from DATA_EXTRA ) ) union
select ds.id from DATA_STANDARD ds, DATA_EXTRA de where
  ( ds.id = de.DS_ID )
  and
  ( de.extra_value = 0 )

--
Remove the dross to contact me directly
Received on Thu Jan 29 2004 - 08:25:11 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US