database - How to append a table to another where the data being appended is not already in the appended table? -


i have 2 tables in ms access want append namely tblmaster , tblnew. problem of data in tblnew in tblmaster. how can append tblnew tblmaster , exclude data in tblmaster?

having specific unique key field easiest - can still accomplish using combination fields unique key (essentially creating own).

you can update linking new table old table, on fields designate should make unique key.

suppose have "employees" table , "employees new" table. want employee's name , badge number form unique key. sql add in records not exist in old employee table.

insert [employees]      ( field1,         employeename,         badgenumber,         field2,         field3,         field4 ) select new.field1,         new.employeename,         new.badgenumber,         new.field2,         new.field3,         new.field4   [employees new] new         left join [employees] old                   on (new.employeename = old.employeename) ,                      (new.badgenumber = old.badgenumber)  (old.employeename null); 

this works linking "employees" table "employees new" using fields determined make primary key. limits results show records new employee not in old employee table already.

the next decision deciding if want update existing records in employee table values in new table. if so, you'd use approach this.

update [employees] old         inner join [employees new] new                    on (old.badgenumber = new.badgenumber) ,                       (old.employeename = new.employeename)     set old.field1 = new.field1,        old.field2 = new.field2,        old.field3 = new.field3,        old.field4 = new.field4; 

this works joining both "employees" , "employees new" table, showing records in both tables unique key fields match. update fields.

hopefully puts in right direction.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -