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: Jan <janik_at_pobox.sk>
Date: 7 Jun 2004 23:46:25 -0700
Message-ID: <81511301.0406072246.5d9fa689@posting.google.com>


What is your SELECT qeury (what do you want to get from it?)

All the EXISTS part is negating the OUTER JOINS:

t1.t2id = t2.id (+) -- here you are asking for all rows from T1 table, but next:

and (

       exists (select 'x' from t2 
              where t1.t2id = t2.id 

you are saying that:
give me just such rows from T1 which exists in T2

So, in fact, you are doing this:

SELECT * ....
  WHERE t1.t2id=t2.id

So define what you need and after we can play with your query.

Jan

emanuelblaser_at_yahoo.com (Emanuel Blaser) wrote in message news:<857de1e3.0406040508.1378bf4f_at_posting.google.com>...
> 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
Received on Tue Jun 08 2004 - 01:46:25 CDT

Original text of this message

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