Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Combining two similar tables in MS Access

  • 25-03-2004 08:30PM
    #1
    Registered Users, Registered Users 2 Posts: 245 ✭✭


    I have two tables with the same column and row headers. One table was updated with new values and the other was not. I need to make sure the latest table has the most uptodate data. so how can i get the data changes into the latest table. I know you are probably thinking, why don't we use the latest table. Well, the problem is that both tables have been worked in at some point. So we need to make one table out of the two of them.

    Thanks


Comments

  • Closed Accounts Posts: 3,354 ✭✭✭secret_squirrel


    I assume you have some way of identifying which rows you want from each table (eg an update flag or a timestamp)

    Copy the structure of one of your tables to a new table, (copy paste should do it.)

    Right assumming the each table has you have 3 fields, a data value, and a timestamp you want something like this :

    insert into table3 (
    Select a.field1,b.field2, c.field3, iif(a.timestamp>b.timestamp,a.value,b.value), iif(a.timestamp>b.timestamp,a.timestamp,b.timestamp)
    from table1 a, table2 b
    where a.field1 = b.field1
    and a.field2 = b.field2
    and a.field3 = b.field3);

    This should work - my MS Sql is very rusty tho... so anyone else feel free to correct me.....


Advertisement
Advertisement