Compare two tables and find matching records in columns

Posted on 2011-11-01
Last Modified: 2012-05-12
How do I compare two tables and find matching records in columns using SQL in access
Question by:StevenHook
    LVL 8

    Accepted Solution

    You can use INNER JOIN to compare two table for matching records.

    If you have 3 columns in two table to find matching records then you can write,
    SELECT Table1.* FROM Table1 INNER JOIN Table2 ON Table1.Column1=Table2.Column1 AND Table1.Column2=Table2.Column2 AND Table1.Column3=Table2.Column3

    If this query returns any result then you have those many matching records. Otherwise no matching records.
    LVL 2

    Assisted Solution

    Comparing two columns

    SELECT tbl1.field1, tbl2.field2
    FROM tbl1 INNER JOIN tbl2 ON tbl1.field1 = tbl2.field2;

    this will show only matches on the two columns (field1, filed2) from two tables (tbl1, tbl2)

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

    754 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

    18 Experts available now in Live!

    Get 1:1 Help Now