Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2012
    Posts
    1

    Unanswered: Consolidating two tables in to one based on Uniqiue ID

    Hey guys,

    Basically what we're doing is sending all of our consignments via our shipping company's website.

    To make our lives easier, they have supplied us with their excel formatted spreadsheet that allows us to upload multiple consignments at once.
    In this spreadsheet, each consignment has two lines, each of which are in separate tables.

    How do I go about extracting them to either another table, or even exporting the to a CSV?

    For example sake, here are the two tables:

    TABLE 1
    Code:
    ID    NAME    ADDRESS           SUBURB   POSTCODE
    
    1     FAKE     123 FAKE ST       RANDO       6666
    2     GUY      124 FAKE ST       RANDO       6666
    3     BOB      172 FAKE ST       RANDO       6666
    4     JILL     1 FAKE ST         RANDO       6666
    5     JANE     77 FAKE ST        RANDO       6666
    TABLE 2
    Code:
    ID    ITEM NUMBER    QUANTITY    NOTES
    1      283                1
    2      233                1
    3      40                 3
    4      94                 7
    5      4334               2

    IN TO:

    Code:
    1     FAKE     123 FAKE ST       RANDO       6666
    1      283                1
    2     GUY      124 FAKE ST       RANDO       6666
    2      233                1
    3     BOB      172 FAKE ST       RANDO       6666
    3      40                 3
    4     JILL     1 FAKE ST         RANDO       6666
    4      94                 7
    5     JANE     77 FAKE ST        RANDO       6666
    5      4334               2


    I don't care if the method is to extract it all in to one table, and then export, or if it can be straight out exported, but at the end of the day, those two lines need to be paired up. Also, in the final product, I realize I haven't added headings - this is because the headings can be anything, it makes no difference.

    Thanks in advance!

    Cheers,
    Brodie

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    I think what you are saying is that two spreadsheets are provided but the content from both need to be uploaded into a single table containing fields for each of the columns in the spreadsheet from both spreadsheets?

    In this case I would export the contents of the files to CSV and then upload both sets into staging tables i.e. tables that you will truncate once we have finished. When the data is loaded then I would write an INSERT ... SELECT statement which inserts the merged entries from both tables into your single table.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •