How can i find difference in 2 tables in different databases with same structure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rizwan6feb
    New Member
    • Jul 2007
    • 108

    How can i find difference in 2 tables in different databases with same structure

    I am developing an application in VB.net 2005 that synchronizes two mysql databases of same structure. I have done most of the work but having problem in finding the difference in records in 2 tables. Let me explain the scenario

    There is a table in the local database having name "user". The same table exists in the online version of the database. I want to find the difference of records in the 2 tables so that i can delete surplus users from the online version of the database. I am trying something like this, which is not working

    Code:
    DELETE FROM localdb.user
    WHERE userid NOT 
    IN (
    SELECT group_concat( userid
    SEPARATOR  ','  ) 
    FROM onlinedb.user
    )
    LIMIT 0 , 30

    I can't afford to select all the records and then find the difference betwen the 2 tables
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    You should be able to simply do:
    [CODE=mysql]
    DELETE FROM localdb.user
    WHERE userid NOT
    IN (
    SELECT userid
    FROM onlinedb.user
    )
    LIMIT 0 , 30
    [/CODE]

    Comment

    Working...