Re: help with interesting 'query'

From: Kris Klindworth <kris.klindworth_at_carle.com>
Date: 1998/08/19
Message-ID: <35DB5250.4774B78B_at_carle.com>#1/1


Dave wrote:

>
>
> create table foo
> (
> id varchar (10)
> f1 varchar (5)
> f2 int
> f3 varchar (5)
> f4 int
> f5 varchar (5)
> f6 int
> f7 varchar (5)
> f8 int
> )
>
> create table fooExtended
> (
> id varchar (10)
> f1 varchar (5)
> f2 int
> f3 varchar (5)
> f4 int
> f5 varchar (5)
> f6 int
> f7 varchar (5)
> f8 int
> )
>
> one is obviously a copy of the other. the contents of foo will be
> overriden on a daily basis - we purchase our data from an outside
> provider. however, we extend the data by changing the value of some
> subset of the non-primary key fields (id is the primary key). i need to
> be able to perform a query that given an 'id' will retrieve any non null
> values from fooExtended but if a field is null in fooExtended will
> retrieve its value from foo.
>

If I understand your problem, you want something like this...

select

    foo.*
from foo, fooExtended
where foo.id=fooExtended.id and fooExtended.f1 is null union
select *
from fooExtended
where fooExtended.f1 is not null
;


Kris Klindworth                 kris.klindworth_at_carle.com
Oracle DBA                     602 West University
Carle Clinic Association        Urbana, IL 61801
Received on Wed Aug 19 1998 - 00:00:00 CEST

Original text of this message