Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    5

    Unanswered: Newbie select question

    I have 2 tables with email addresses. I need to get the email addresses from the "old" table that are not in the "new" table. A DBA I know suggested:
    SELECT Email FROM Old WHERE Email NOT IN (SELECT Email FROM New)
    It did not work.

    TIA

    Mark C

  2. #2
    Join Date
    Mar 2004
    Posts
    480
    What does "it did not work" mean?
    Did you get no results? Did you get an error message?
    what version of MySQL are you running?

  3. #3
    Join Date
    Jul 2004
    Posts
    5
    I got an error message pointing to the SELECT in the ().

    I am running 3.23.58

  4. #4
    Join Date
    Mar 2004
    Posts
    480
    The reason you are getting an error message is that you can't use subqueries before version 4.1

    You can do this with a join though:

    Code:
    SELECT oldemailaddress 
    FROM oldtable AS old
    LEFT OUTER JOIN 
    newtable as new
    ON old.oldemailaddress = new.newemailaddress
    WHERE new.newemailaddress IS NOT NULL

  5. #5
    Join Date
    Jul 2004
    Posts
    5
    Not quite, but close. For the sake of anyone reading this later the following worked:

    SELECT old.email FROM oldemail AS old LEFT OUTER JOIN newemail AS new ON old.email = new.email WHERE new.Email IS NULL

    Thanks for the help!!

Posting Permissions

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