Results 1 to 3 of 3
  1. #1
    deso is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2013
    Location
    brisbane, australia
    Posts
    23

    add field from one table to another table

    hi guys, i have two tables, and I want to add a field (column) from Table B to Table A. Both tables have an ID field, but both tables do not contain the same number of IDs. Also both tables contain duplicates of each ID. In table B, there is a temperature field I want to add to Table A, and i need the sampledate field associated with the temp field to transfer across also (so i really need to add two fields to table A). The duplicates in each table are water chemistry readings for the same site on different days. I need the duplicates. A simple example is below

    Table A:
    ID sampledate pH HCO3 SO4 TDS
    1 june 5 2 3 4
    2 july 7 3 4 6
    3 august 6 5 5 5
    5 september 6 6 6 6

    Table B
    ID sampledate temp xxx yyy
    3 september 20 blabla blabla
    4 october 25 blabla blabla

    I need the result to look like this

    ID sampledate temp pH HCO3 SO4 TDS
    1 june "null" 5 2 3 4
    2 july "null" 7 3 4 6
    3 august "null" 6 5 5 5


    3 september 20 "null" "null" "null" "null"
    4 october 25 "null" "null" "null" "null"
    5 september "null" 6 6 6 6

    In the past I have used UNION queries to do this, and just made blank fields in each table to make sure each table has the same number of fields. However, I will need to perform this query multiple times, and there are about twenty fields in table A so i don't want to have to create that many blank fields just so I can use the UNION query. And I know I can't use the APPEND query.

    is it posibble to achieve what I am trying to achieve in access?

  2. #2
    deso is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2013
    Location
    brisbane, australia
    Posts
    23
    i've tried this to see if i can just simply combine the two tables but get an expression error (still, it's using a union query which i thought couldn't be used)

    SELECT * FROM TABLEB LEFT OUTER JOIN TABLEA ON=0
    UNION
    SELECT * FROM TABLEB RIGHT OUTER JOIN TABLEA ON=0

  3. #3
    deso is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2013
    Location
    brisbane, australia
    Posts
    23
    btw, i just did a count and tableA contains 64 fields......i really don't want to add 64 fields to a new table every time I need to run this query just so i can use a UNION query. Any help would be great....there has to be a way to get around the fact that each table contains a different number of fields.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-13-2013, 06:30 AM
  2. Replies: 5
    Last Post: 11-01-2012, 09:26 AM
  3. Replies: 2
    Last Post: 10-24-2012, 02:53 PM
  4. Replies: 5
    Last Post: 03-01-2012, 12:59 AM
  5. Replies: 4
    Last Post: 09-03-2009, 02:01 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