Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL ?? - Insert from multiple tables
Probably you need to use outer join feature of Oracle SQL.
Sincerely
Maris Gabalins
mg_at_it.lv
Dina April wrote:
> Hi -
>
> I am ahving a problem with the following SQL statement:
>
> insert into table1
> (fld1, fld2, fld3)
> select
> a.fld1,
> b.fld2,
> 'test value'
> from
> table2 a,
> table3 b
> where
> a.fldx = 'val1' and
> b.fldy = 'val2'
>
> What happens:
>
> If there is no record in table3 (b) where fldy = 'val2',
> the new record is not inserted into table1
>
> What I want to happen:
>
> If there is no record in table3 (b) where fldy = 'val2',
> the new record is inserted into table1 and fld2 is set to NULL
>
> How can I modify my SQL statement to do this?
>
> Thanks.
>
> Dave
> --
> David S. April Syclo LLC
> (847) 842-0320 101 Lions Dr. - Suite 118
> april_at_syclo.com Barrington, IL 60010
>
> "Paradise is exactly like where you are right now, only much, much, better."
> - Laurie Anderson
Received on Thu Oct 09 1997 - 00:00:00 CDT