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

Home -> Community -> Usenet -> c.d.o.server -> Re: A query without a sub-query: can we do it?

Re: A query without a sub-query: can we do it?

From: Atta ur-Rehman <atta707_at_my-deja.com>
Date: Thu, 23 Nov 2000 05:34:23 GMT
Message-ID: <8via8v$qu3$1@nnrp1.deja.com>

In article <8vgp85$pn1$1_at_nnrp1.deja.com>,   David Fitzjarrell <oratune_at_aol.com> wrote:
> In our last gripping episode Atta ur-Rehman <atta707_at_my-deja.com>
 wrote:
> > dear all,
> >
> > i've following table named lab with user_id, lab_id as the PK:
> >
> > select * from lab;
> >
> > USER_ID LAB_ID
> > ---------- ----------
> > 2 1
> > 2 2
> > 2 3
> > 9 3
> > 9 4
> > 9 5
> > 9 6
> >
> > now i wanna see all the labs where user_id 2 is a member except for
 the
> > labs where 9 is a member as well, then i'd say:
> >
> > select * from lab
> > where user_id = 2
> > and lab_id not in (select lab_id from lab where user_id = 9);
> >
> > that results in:
> > USER_ID LAB_ID
> > ---------- ----------
> > 2 1
> > 2 2
> >
> > and rightly so. user_id 2 belongs to lab 1, 2 and 3. lab 3 has not
 been
> > selected 'cas user 9 is a member of this lab. great!
> >
> > now my question is: can i write the same query without having to use
> > the sub-query as i've done above? if yeah, how? theoratically
 speaking
> > is there *always* an equivilant SQL statement for every query that
 uses
> > with sub-query?
> >
> > thanks in advance for any help.
> >
> > :) ATTA
> >
> > --
> >
> > getting the meanin' of data...
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> This sounds like homework to me, and I'm reluctant to offer a solution
> knowing you have far more time to decipher this problem than those of
> us who work for a living. Be that as it may you can try this:
>
> select lab_id
> from lab
> where user_id = 2
> minus
> select lab_id
> from lab
> where user_id = 9
>
> No formal subquery there.
>
> Also, since you are a student it would behoove you to use correct
> verbiage in written communication with others. Your post would not be
> tolerated in the 'real' world.

Thanks very much indeed, David, for the suggestion. students, we all are; arn't we? and i truly regret using any verbiage that you didn't find befitting for the forum or the 'real' world for that matter. having gone through the orginal mail contents i couldn't find anything which, in my opinion, should be offending or outrageous though. 'informal' may be the best way describing it the way it was written in. anyhow, i truly value your postings on this forum along with other 'regulars' like Sybrand, Howard, Steve, Jonathan and until coupla months back Thomas and others and again regret anything that you found loathsome.

regards,

ATTA
>
> --
> David Fitzjarrell
> Oracle Certified DBA
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

--

getting the meanin' of data...


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Wed Nov 22 2000 - 23:34:23 CST

Original text of this message

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