SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Feb 2004
    Location
    Netherlands
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SELECT ALL records that are not in table 2

    Hi there,

    Table #1
    ------
    ID

    Table #2
    -----
    SubscriberID

    I Need all Records from Table #1 WHERE ID IS NOT SubscriberID

    So, all records from table #1 which ID is not in table #2

    Code:
    SELECT * FROM `table_1`, `table_2` WHERE 
    ID <> SubscriberID
    It does not work this way,

    Somebody got any suggestions?

    Thanks in advance

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I think that the following query should do the trick.

    Code:
    SELECT * FROM table_1 as ta
      LEFT JOIN table_2 as tb ON tb.SubscriberID = ta.ID
    WHERE tb.SubscriberID IS NULL
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Addict
    Join Date
    Feb 2004
    Location
    Netherlands
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    works like a charm. Thank you very much


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
  •