1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2013
    Rep Power

    Combine Tables with a Twist

    I am trying to figure out how to do a task in Access and hopeful someone here can help me out.

    What I have is three tables that all relate to wholesalers inventory and products.

    One is my main table that has product item number (1st column), descriptions, etc. This table has 15.5k items/ product numbers.

    Second table has attributes for some of the products that are in the main file. It also has in the first column the item number of the product. Note: not all products in main file have attributes. This table has about 13k items/ product numbers.

    Third table has item number column then a column with item numbers that are cross sell items. It also has a category/ department no. column (third column) for the second column item numbers. This table has about 12k item numbers.

    What I want to do is combine all three of these files into one table. Of course item numbers (first column) from the second and third table should match to the appropriate item numbers in the main table but not repeat item number.

    If anyone understands this could you please help.

    Thank you - Robert
  2. #2
  3. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Jun 2011
    South Jersey
    Rep Power
    If I understand you correctly then your third table has two (or more) foriegn keys. If your goal is simply make one table out of the three, then table two and table three with the first foreign key are a simple matter. What ever process you use to add the records of tables 2 and 3 to your current table (Update query?) you will just repeat seperately again for table 3. This time however just change your relationship from the first forign key to the second (or third, or fourth)

    The second table is pretty cut and dry. If your primary key is also your foriegn key, then you can easily combine it with your main table. Two seperate tables are probably not necessary. On your third table, because 1 record could relate to multiple records of your main table, you may want to consider leaving it as is. It may be more efficient to add a foriegn key to your main table to refer to your thrid table.
  4. #3
  5. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2004
    Rep Power
    Just to give a little more detail to the answer above:

    To combine the first two tables, go into design view for table1 and add any fields that only exist in table2. Then, create an update query to move the data from the second table into the first. Assuming there's only one extra field in the second table, called 'attribute', it'd look something like this:

    UPDATE [table1] INNER JOIN [table2] ON [table1].[item_number] = [table2].[item_number]
    SET [table2].[attribute] = [table1].[attribute];
    I'm afraid I don't quite understand the third table - what's a cross sell item? As meratigoerr says, if one item number can have more than one cross sell item (ie the same item number appears more than once in the table) it's not a good idea to combine it with the first table. If each item can only have a single cross-sell item then you can follow the same procedure as given above.

Similar Threads

  1. combine different rows from 2 tables into 1 row
    By nickblitz in forum ASP Free Lounge
    Replies: 0
    Last Post: November 5th, 2012, 03:22 AM
  2. Combine multiple tables into 1
    By kyengineer in forum Microsoft Access Help
    Replies: 3
    Last Post: February 24th, 2012, 09:11 PM
  3. Combine several tables to !
    By speight in forum Microsoft Access Help
    Replies: 2
    Last Post: September 9th, 2008, 11:35 AM
  4. create a DTS for two tables to combine
    By sonia in forum SQL Development
    Replies: 5
    Last Post: July 25th, 2005, 08:28 PM
  5. How can I combine two tables in Access?
    By dallagmm in forum Microsoft Access Help
    Replies: 2
    Last Post: January 9th, 2005, 07:27 PM

IMN logo majestic logo threadwatch logo seochat tools logo