Help with updating records with a query (1 Viewer)

slogie

Registered User.
Local time
Today, 00:51
Joined
Aug 27, 2012
Messages
25
Hi again,

I don't know much about queries, but I need to update some prices in my database. I however started doing them manually and then the light bulb finally went off in my head and I figured I could use a query. Is there a way for me to run the query on the remaining records without disturbing the records I had changed manually, or do I have to update all the records? So far, the update query that I did would update all the records, which means I would have to go back and change back the prices I had already changed. Any advice??
 

isladogs

MVP / VIP
Local time
Today, 05:51
Joined
Jan 14, 2017
Messages
18,216
The answer depends on how the update is done & how you can identify the records that have been updated manually
Do you have a date updated field or a yes/no field to indicate those already done?
If not, how can you tell which you've done?
Also, how many have you done & would it be quicker to undo those changes & then update the lot?
 

slogie

Registered User.
Local time
Today, 00:51
Joined
Aug 27, 2012
Messages
25
Hi, thanks for replying.

No, I don't have an update field. As stated before, I was manually going through the records and changing the values. So far I changed up to the first 100. I only have about 470 records and if I ran the update query, it would change all the records, including those which I have already changed.

If it can't be done, then yes I can undo the changes I had made and then run the query, but I just wanted to know if it was possible.
 

isladogs

MVP / VIP
Local time
Today, 05:51
Joined
Jan 14, 2017
Messages
18,216
Do you have a backup from before you started updating the records manually?
 

slogie

Registered User.
Local time
Today, 00:51
Joined
Aug 27, 2012
Messages
25
No I don't, but it's just a fixed percentage that I would be adding to the prices.
 

isladogs

MVP / VIP
Local time
Today, 05:51
Joined
Jan 14, 2017
Messages
18,216
OK - FIRST make a backup

Then COPY just the records you have already updated to a new 'temp' table.
Create an update query on the temp table to reverse that update
So if, for example, you were adding 5% to the price by multiplying by 1.05 then you need to now divide by that amount

Next join the main & temp tables together & run a further update query to update the main table to the values in the 'temp table'
If the values are correct, you can delete the temp table

Next add one or more fields as previously suggested so you can flag updated records in future
Finally run a new update query on all records in the main table
And then make another backup!
 

Users who are viewing this thread

Top Bottom