Results 1 to 2 of 2

Thread: please help its driving me nuts

  1. #1
    Join Date
    Nov 2002
    Posts
    13

    please help its driving me nuts

    Please can some 1 help me

    I have 3 tables
    1 with contacts in
    1 with groups in
    and 1 to link the 2 together

    each contact and group have id's which are used in the link table

    i need 2 sql queries
    1 saying which contacts are in each group (i think ive cracked this)
    and 1 saying which contacts are not in each group(which i need help)

    Some 1 please help its driving me nuts

  2. #2
    Join Date
    Feb 2003
    Posts
    102

    Use NOT EXISTS

    Minkle,

    Now this one was fun...

    Try

    SELECT C.ContactName, G.GroupName
    FROM Contacts as C, Groups as G
    WHERE NOT EXISTS (
    SELECT CG.ContactID, CG.GroupID
    FROM ContactGroups as CG
    WHERE CG.GroupID = G.GroupID AND
    C.ContactID = CG.ContactID)

    HTH,

    Peter

Posting Permissions

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