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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Select Statement?! (Oracle 9i)

Re: Select Statement?! (Oracle 9i)

From: Daniel Morgan <damorgan_at_x.washington.edu>
Date: Fri, 04 Jun 2004 17:22:24 -0700
Message-ID: <1086394954.754519@yasure>


Emanuel Blaser wrote:
> Hi
>
> Need some help creating a sql statement the best way.
>
> Description:
> I have one table (T1) with three foreing keys to table T2, T3, T4.
>
> If only one of the three relation is good (doesen't matter wich) i
> want do get a result. I can't check only the fields in table T1 cause
> it's possible that there are deadlinks and also every table has a
> deleteflag, if it's set i have to ignore the row)
>
> How i would do this:
> select * from t1,t2,t3,t4
> where t1.t2id = t2.id (+) and t2.deleteflag (+) <> 1
> and t1.t3id = t3.id (+) and t3.deleteflag (+) <> 1
> and t1.t4id = t4.id (+) and t4.deleteflag (+) <> 1
> and (
> exists (select 'x' from t2
> where t1.t2id = t2.id and t2.deleteflag <> 1)
> or exists (select 'x' from t3
> where t1.t3id = t3.id and t3.deleteflag <> 1)
> or exists (select 'x' from t4
> where t1.t4id = t4.id and t4.deleteflag <> 1)
> )
> and t1.deleteflag <> 1
>
>
> Maybe this is the best way to do it but i don't think so.
>
> Thanks for your help
> Emanuel

As suggested by Alan use UNION or use in-line views.

-- 
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Fri Jun 04 2004 - 19:22:24 CDT

Original text of this message

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