#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    266
    Rep Power
    11

    SQL statement for 2 tables?


    I have two tables: GroupName and SelectGroup

    GroupName:
    Code:
    GroupID
    Name
    SelectGroup:
    Code:
    UserID
    GroupID
    on my website, I have dropdown menu box that display the data from table: GroupName.

    What I like to do is on the dropdown menu only display the items that has not been selected by that UserID. The UserID is just a URL querystring.

    Can someone please help me how to do about this?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    266
    Rep Power
    11
    Found my solution here

    SELECT a.i
    FROM #a AS a
    WHERE a.i NOT IN (SELECT b.j FROM #b AS b)
    OR a.i IS NULL
  4. #3
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,150
    Rep Power
    4274
    remove OR a.i IS NULL
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo