+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Mar 2005
    Posts
    93

    Question Database: Comparing values in two different tables

     
    Hello all,

    I hope someone can answer this question!

    I am trying to compare two columns from a table with one column from another table. I need to have the rows from the first table that aren't contained in the second table.

    The "problem" is that I have around 800K records on each table.

    Has anyone tried to do this in a home computer (2 Gb RAM 1.79 GHz Centrino Duo)?

    If you have, how long did it take?

    If you haven't, what's your guess? How long will it take?

    The DBMS is MySQL running on Windows.

    Thank you all!!!

  2. #2
    Not Really a Member
    Join Date
    Oct 2001
    Posts
    27,856
    how long it will take is heavily dependant on if the columns are indexed

    I think mysql now supports 'join' syntax?

    you could do something as simple as
    select *
    from t1
    left outer join t2
    on t1.column1 = t2.column1

    obviously changing the table/column names

    this is written for t-sql so some minor syntax changes maybe necessary for mysql

    what you're asking for is a pretty common outer join
    it maybe a right outer join, so if left doesn't give you the correct results try a right outer join
    Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.

  3. #3
    Caveat Emptor Rootstonian's Avatar
    Join Date
    Mar 2005
    Location
    Out of my mind
    Posts
    3,326
    Code:
     I've always done:
    select
    t1.column1,
    t1.column2
    from table t1
    where not exists (select 'x'
                                  from table t2
                                  where t1.column1 = t2.column
                                 and      t1.column2  = t2.column)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need values
    By TheBigCarp321 in forum Processors, Memory, and Overclocking
    Replies: 5
    Last Post: May 2nd, 2006, 10:13 PM
  2. CHS values on my HD are incorrect.
    By hav0c in forum Storage Related
    Replies: 1
    Last Post: January 5th, 2006, 04:41 AM
  3. Family values
    By Theophylact in forum IMO Community
    Replies: 7
    Last Post: March 9th, 2004, 02:15 AM
  4. Conversion Values
    By washe in forum Graphic Design and Digital Photography
    Replies: 3
    Last Post: August 12th, 2002, 07:17 PM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews