My Assistant
![]() ![]() |
|
|
Jan 26 2010, 09:22 AM
Post
#1
|
|
|
UtterAccess Guru Posts: 929 From: Lytham St Annes, Lancashire, UK |
I have created an append query - very basic.
INSERT INTO [tblYC-Users] ( fldUserID, fldName, fldUserName, fldEmail, fldRegistered, fldEmailRespond, fldDateRegistered, fldDateLastVisit ) SELECT YC_Users.id, YC_Users.name, YC_Users.username, YC_Users.email, YC_Users.usertype, YC_Users.block, YC_Users.registerDate, YC_Users.lastvisitDate FROM YC_Users; each day or two I want to run it so that the latest additions to the source which is a linked spreadsheet get appended to the existing data. So I need to set criteria to NOT append records that already exist. The best field to use is the Users.id which appends to fldUserID. This is what I have tried but it does not work. INSERT INTO [tblYC-Users] ( fldUserID, fldName, fldUserName, fldEmail, fldRegistered, fldEmailRespond, fldDateRegistered, fldDateLastVisit ) SELECT YC_Users.id, YC_Users.name, YC_Users.username, YC_Users.email, YC_Users.usertype, YC_Users.block, YC_Users.registerDate, YC_Users.lastvisitDate FROM YC_Users WHERE ((YC_Users.id<>[tblYC-Users].fldUserID)); It does not like the [tblYC-Users].fldUserID)); bit. What am I doing wrong? TIA Alan |
|
|
|
Jan 26 2010, 10:01 AM
Post
#2
|
|
|
UA Admin Posts: 19,376 From: Newcastle, WA |
There is a query wizard that will help you create the basic query for this, which you can turn into the append query.
The Query Wizard option is "Find Unmatched Query Wizard". Use it to find all records in your import table (the linked spreadsheet) which do not appear in the destitnation table (tblYC-Users). Then, you can change it to the append query. The query works by using a LEFT JOIN between the two tables on the two Key fields (UserID). A left join returns ALL records from the first table and only matching records from the second. The "Find Unmatched Query Wizard" adds a criteria so that only records that are not found in the second table are returned. You can examine the results of the query wizard to see how this works. HTH George |
|
|
|
Jan 26 2010, 10:13 AM
Post
#3
|
|
|
UtterAccess Guru Posts: 929 From: Lytham St Annes, Lancashire, UK |
Thanks....did some searching in the interim and found the solution you suggested. We will see what transpires when next I append :-)
Alan Stuck in Newbie mode :-( |
|
|
|
Jan 26 2010, 09:12 PM
Post
#4
|
|
|
UA Admin Posts: 19,376 From: Newcastle, WA |
Glad to hear you found a solution. The ones we develop ourselves are always the most satisfying.
Continued success with your project. George |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th June 2013 - 11:46 AM |