How to query two tables and merge the results?

Posted on 2004-11-01
Last Modified: 2013-12-24
I have two tables in Access, table A and table B.  I want to query both tables, find the like records and unlike records, and then display the results in Excel.  If the record exists in both tables, I only want to show the record from table A.

Can someone provide a code example for me to go by?
Question by:g118481
    LVL 22

    Expert Comment

    Hi g118481,
    you should post this question in mssql area they will be able to give you quick reply.

    LVL 35

    Expert Comment

    Actually you should post in the Accesss area - not MySql - and you need to post more information such as what do the tables look like?  What is the filed that they have in common that you want to compare.  DO you want to compare just existance of a single field or differences accross records?
    LVL 1

    Author Comment

    MySQL and Access forums would not be able to help with how and where to us CFLOOP nor any CF conditional statements for this request.

    I want to query table A and table B, find the like records in both and the records that are not alike, but only display the like records for table A and display the records that are not alike.  So, if a record exist in table B, but not in table B, then display it.  If a record exist in table A and table B, the display the record in table A, but not the record in table B.

    Both tables have like named fields.  Here are the field names:

    LVL 35

    Accepted Solution

    Yes, but once you have the queries that pull what you want you can easily display them.

    Do you want to compare just existance of a single field or differences accross records?

    Try something like this and see if it is waht you want....

    SELECT *
    FROM table1 t1
    LEFT OUTER JOIN table2 t2
    ON = IS NULL

    this will pull all records that are in table 1 that  are NOT in table 2.  It works in SQL, but may need a bit of modification depending on the version of access....

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
    Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
    Want to pick and choose which updates you receive? Feel free to check out this quick video on how to manage your email notifications.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    913 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

    12 Experts available now in Live!

    Get 1:1 Help Now