Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2003
    Posts
    65

    Unanswered: Select Statement

    Hey,

    I have 2 tables

    Teams (TeamID, Name, CodeID) <--TeamID PK, CodeID FK

    Round (GameID, Round, HTeam, ATeam, CodeID)

    GameID PK, HTeam and ATeam FK, reference TeamID, CodeID FK

    I want to select all Teams(TeamID, Name)
    Where TeamID is not in (Round [as HTeam or ATeam] Where CodeID=@CodeID AND Round=@Round)

    so

    Select TeamID, Name
    From Teams
    Where (how do I do the not in thing?)

    is there some form of exclusion semi join or something?

    Thanks,
    -Ashleigh

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Either this is what you want or else if it is not .. can you explain the problem in detail

    Code:
    select 
    	TeamID, Name
    from 
    	Teams 
    where 
    	teamid not in (
    			select ateam  "teams" from round where Round=@Round 
    			union select Hteam  "teams" from round where Round=@Round\
    		       )
    and CodeID=@CodeID
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  3. #3
    Join Date
    Sep 2003
    Posts
    65
    yeah, that's it.


    'not in'

    didn't know that was a sql term, lol.

    I need a good sql book. Someone tell my boss it's worth the $100 or so bucks, lol.

    Cheers mate
    -Ashleigh

  4. #4
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    You dont need anything else than the holy book (SQL Server books online )
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  5. #5
    Join Date
    Sep 2003
    Posts
    65
    Originally posted by Enigma
    You dont need anything else than the holy book (SQL Server books online )
    That the resource that comes with MS SQL server? or another one?
    -Ashleigh

  6. #6
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Yup !! Thats the one !!!
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

Posting Permissions

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