DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: query help

  1. #1
    Join Date
    Feb 2001
    Location
    Master Control
    Posts
    86

    query help

    I was hoping someone could help me with a query...I am thinking that I need an 'IN' statement, however I am not sure. Here is what my tables look like:

    tblGroups
    ---------
    group
    ---------
    groupA
    groupB
    groupC

    tblBridge
    ---------
    user | group
    ---------
    userA | groupA
    userA | groupB
    userB | groupC
    userC | groupA

    Basically I want my query to show only the groups that userA is NOT a member of...which is just gorupC. Any ideas?

  2. #2
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    select group from tblGroups
    where group not in
    (
    select group by tblBridge where user='userA'
    )

    ... or ...

    select group from tblGroups
    minus
    select group by tblBridge where user='userA'

    ... or ...

    select group from tblGroups g
    where not exists
    (
    select group by tblBridge t where user='userA'
    and t.group = g.group
    )

    ... or ...

    some other methods.



    I like the minus operator.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width