Data Comparision

Posted on 2004-11-10
Last Modified: 2010-05-02
I have a following problem.
i opened two connections conn and conn1 so i opened 2 tables from different 2 databases.
but both tables have the joining fileds employee_id and date1.
but i want to fetch only those records which are not same in both tables.

            Table1(Conn)                                  Table2(Conn1)
Employee_id            Date1                     Employee_id            Date1
    13265              11/09/2004               13265              11/09/2004
    13526              11/10/2004               13265              11/09/2004  
    13589              11/11/2004

So i want compare two different databases tables and extract only employeee_id 13589 or "nth employee_ids."
and result in flexgrid.

Question by:azharmateen
    LVL 3

    Accepted Solution

    You dont have to create two seperate connection for this situation. Create a single recordset having left join from table1 to table2 and filter this so that only records that exist in table one and not in table2 appears.
    create your recordset like:

    SELECT * FROM Table1 LEFT JOIN Table2 ON (Table1.Employee_id= Table2.Employee_id) AND (Table1.Date1= Table2.Date1) Where Table2.Employee_id Is Null

    havent tested code above but this should work. hope this helps:)

    Author Comment

    But i must  need two different connections.
    LVL 3

    Expert Comment

    Then create your two connection if you really need it. then have a seperate one for the recordset above. update the recordset above everytime theres a change in the first two for you to see the changes.:)
    LVL 2

    Assisted Solution

    I would say that prior to the comment given by Noel, I think you should give this statement

    sql = "select * into tbl2 from table2 in '" & path of the second database goes here & "'

    This will put both the tables in the same database.

    Then u can run the distinct query statement given by Noel
    LVL 2

    Expert Comment

    U can give the points to Noel_castillo, as that is a right procedure
    LVL 3

    Expert Comment

    I think we both gave the solution for this question. Because i havent noticed that its from 2 different databases. Thus the points should be splited. :)

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now