Not sure what exactly your db set up is, but for me I solved a similar issue using some simple PLSQL.
Let's say you have two tables:
- "request" table with many columns one being a "date" column and its primary key being "id"
- "item" table with many columns with one also being a "date" column and another being a pointer to the request it belongs to called "request_id"
And let's say this is for when a user is making a purchase request for one or more items, a one to many relationship, and so the date columns on the items should match that of the request they belong to.
Now let's say the date column on the request has been left blank accidentally but thankfully not the dates of the items. And so we want to updated the request date column to match that of their corresponding items' date value. And so for each request, take one of its items and take the item.date and set the request.date to this item.date using PLSQL:
begin
for iteration_row in
(select distinct r.id as r_id_from_select, i.date as i_date_from_select
from request r
join item i on item.request_id = r.id)
loop
update request r_to_update
set date = iteration_row.i_date_from_select
where r_to_update.id = iteration_row.r_id_from_select
end loop;
end;
Another example of PLSQL looping through the select but this one is not updating like I am above:
https://stackoverflow.com/a/49635601/2888009
COMMIT- try it for 2 small departments first, check the results, issue aROLLBACK.