SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2006
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select Differing Data

    Hi,

    Using SQL Server 2005.

    How do I select all id's from table B that are not in table A??

    Tried below but returns no values when it should...

    Code:
    SELECT b.ID
    FROM btbl b
    INNER JOIN atbl a
    ON a.ID = b.ID
    WHERE a.ID != b.ID
    Thanks.

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    Blackpool, UK
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SELECT ID
    FROM b
    WHERE ID NOT IN (SELECT ID FROM a)
    dt digital : internet design & consultancy

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2006
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,014
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    Code:
    SELECT b.ID
    FROM btbl b
    LEFT OUTER JOIN atbl a
    ON a.ID = b.ID
    WHERE a.ID IS NULL
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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