Results 1 to 6 of 6
  1. #1
    rohini is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    41

    compare two tables and populate a third one accordingly

    Dear all,



    I have a basic table that has a list of all codes possible - 'basic'

    I have two tables, each with some information with respect to a code. It is not necessary for each code to be present here. in the given example, these two tables are 'input1' and 'input2'

    i would like to integrate the data from these two tables into one using basic as a guideline. this should give me the table 'output'.

    could you please tell me how this can be done?

    Thanks
    Attached Files Attached Files

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Assuming the code is the common field, you can do this two different ways. You can either join all three tables on the code in a select query. Once you have done this, change the query to a make table query. Or you can add the two new fields to the table basic in design view. Then run an update query to take the data from the two input tables to the basic table.

    Alan

  3. #3
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Assuming the code is the common field, you can do this two different ways. You can either join all three tables on the code in a select query. Once you have done this, change the query to a make table query. Or you can add the two new fields to the table basic in design view. Then run an update query to take the data from the two input tables to the basic table.

    Alan

  4. #4
    rohini is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    41
    hey i did not really get you. code can be the common field but some of the codes are not present in input1 and some others are not present in input2 while some aren't present in either. so how do i make it a common field, i will only get those entries here which are present in input1 and input2. while i want all those that are present in input1 OR input2 or those in neither also to remain ....

    if possible please make this query on the file i have attached so that i can see what you are saying..

  5. #5
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Look at Query1. After looking at it, change it to a make table query. Run it by selecting the exclamation point icon.

    Here is the SQL statement
    Code:
    SELECT basic.Code, input1.location, input2.sale INTO basic
    FROM (basic LEFT JOIN input1 ON basic.Code = input1.code) LEFT JOIN input2 ON basic.Code = input2.code;
    You ensure that you capture all codes from the first table by left joining it to the other two codes.
    Attached Files Attached Files

  6. #6
    rohini is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    41
    thanks a lot!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 01-30-2012, 08:32 AM
  2. Compare records in 2 tables
    By RalphJ in forum Access
    Replies: 13
    Last Post: 03-06-2011, 07:43 AM
  3. Compare tables and tell me differences
    By cowboy in forum Programming
    Replies: 2
    Last Post: 08-11-2010, 08:32 AM
  4. Compare two tables
    By Igli in forum Access
    Replies: 2
    Last Post: 07-05-2010, 10:30 AM
  5. Replies: 3
    Last Post: 05-19-2010, 10:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums