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 -> Quick nested SQL question

Quick nested SQL question

From: Rich <richmun_at_yahoo.com>
Date: Fri, 15 Nov 2002 14:48:25 GMT
Message-ID: <ZO7B9.9383$%m4.2326@rwcrnsc52.ops.asp.att.net>


Howdy. Ok it's an ugly SQL statement. But I wonder if it should work?

I have a user table t_user, and a group of friends (of the users) table t_group.

Looks like this

T_USER

ID                   FIRSTNAME           ...............................

----------------------------------------------------------
409 RICH 500 JIM 600 BOB 700 TOM

T_GROUP

ID                   FRIEND_ID          ...............................

----------------------------------------------------------
409 500 409 600

I want to be able to select records in t_user for RICH but exclude RICH's FREND_ID's (He's already added them so I don't want to give him a choice on the GUI.

Or is there a better way to execute this?

Here is my first shot at it.

select t_user.id , t_user.firstname, t_user.lastname from t_user, t_group -   where (t_group.friend_id) in -
    ( -

       select t_group.friend_id from t_group where (t_group.friend_id) NOT IN -

       ( -
         select t_group.friend_id from t_group where t_group.id = '406' -
       ) -

    );

Any help would be appreciated. Thanks

rich Received on Fri Nov 15 2002 - 08:48:25 CST

Original text of this message

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