Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2005

    Unanswered: Will a JOIN get me there?

    The situation:

    I have two tables. First table has 3,000 - 4,000 records [userID, firstname, lastname, dateJoined, etc...]. Second table has about 100 records [userID, status, date, etc ...]. The database is MySQL v4.0.27 and I'm talking to it with phpMyAdmin 2.6.4-pl2.

    What I want to accomplish:

    I want to return all records in the FirstTable where the userID does not exist as a userID in the SecondTable. This sounds simple to me but I just haven't been able to get it to work.

    Any advice from the fine minds at would be greatly appreciated.

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    yes, a join will get you there

    specifically, a LEFT OUTER JOIN where FirstTable is the left table and SecondTable is the right table, with a WHERE clause to check IS NULL in the right table's join condition

    there's an example of this here -- | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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