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: help me to improve sql, plz

Re: help me to improve sql, plz

From: Ed prochak <ed.prochak_at_alltel.com>
Date: 12 Mar 2002 10:07:48 -0800
Message-ID: <e51b160.0203121007.581e1489@posting.google.com>


In what way do you want to "improve" the query?

 I have one obvious question: Why are you using a subquery??
> (ir.figw in (select fiid from gw) or ir.figw is null)
It seems you are trying to do outer joins in both directions. What rows do you really want this query to return? GIVE A SPECIFIC EXAMPLE please.

(Hint: make two sample tables with 2 or 3 rows each with only 2 or 3 columns. show your complete query using these sample tables. IOW, do not use "....")

Let's see table IR has column figw, GW has column fiid. Apparently figw allows NULL (not sure about fiid). Let's assume in IR rows have figw
  1
  2
null

and in GW rows have
fiid
  2
  3

in the result you get with this query
figw fiid
  2 2
null null

Seems to work fine. Alexei, what do you think is wrong??

HTH,
  Ed

af_at_ipclearingboard.com (Alexei Fedotov) wrote in message news:<e6d56cc2.0203120017.4e12b359_at_posting.google.com>...
> no aggregations, no functions, consider only these two tables, selecting any fields
>
> select *
> from ir, gw
> where
> (ir.figw in (select fiid from gw) or ir.figw is null)
> and ir.figw = gw.fiid (+)
>
> it is an outer join but we cannot guarantee the data consistency
>
> damorgan <dan.morgan_at_ci.seattle.wa.us> wrote in message news:<3C742B33.C22B6BBD_at_ci.seattle.wa.us>...
> > If you had actually provided some SQL someone could. What is this?
> >
> > Are you selecting any fields? Doing any aggregations? Using any functions?
> > Linking an unending list of tables? Connecting the tables via what fields?
> >
> > Daniel Morgan
> >

-- 
Edward J. Prochak   --- Magic Interface, Ltd.
Ofc: 440-498-3700
on the web at       --- http://www.magicinterface.com
email: ed.prochak_at_magicinterface.com
Received on Tue Mar 12 2002 - 12:07:48 CST

Original text of this message

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