Question about appending a query to a table

I am appending a query to a table. The question I have is can you replace the old data in the table with the new data from the query without having to go into the table and delete the old data? Right now if you click append twice it will just keep adding the same information. I want it to overwrite the old info in the table.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul Cook-GilesSenior Application DeveloperCommented:
If your table, and the source of the query, share a unique identifier (the primary key), then you can create an update query by matching your table to the source and updating the non-key fields.  Otherwise, run two queries:  a delete query to empty the table, and an append query to copy the data from the source into the target.
Dale FyeOwner, Developing Solutions LLCCommented:
Actually, you can create what many call an UPSERT query, which updates data where it already exists, and appends where it doesn't.  The syntax for that is something like:
SELECT Field1, Field2, Field3
FROM SomeTable
)  AS ST 
LEFT JOIN DestinationTableName as DT 
ON ST.Field1 = DT.Field1   
SET DT.Field1 = ST.Field1
, DT.Field2 = ST.Field2
, DT.Field3 = ST.Field3

Open in new window

You will note that I have a subquery to select the values that I want to insert into the destination table.  You need to make sure that this SELECT subquery contains all of the fields you need to ensure that the records in the recordset you want to update/append from match with those in the destination table

NOTE: Make sure you backup your database before you attempt this.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Do you update the data in the database by any other method except the spreadsheet?  If the answer is yes, then how do you propose to determine which version of the record, field by field, is current?
Gustav BrockCIOCommented:
Yes you can. Follow the few steps here:

Combined "update or append" query
HOTWATTAuthor Commented:
Thanks for the help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.