Update Fields only if there is no value

clayt101

Board Regular
Joined
Nov 26, 2008
Messages
55
I want to use an update query to update the values in a column, but only when there is no pre-existing value.

Will this query work:

Code:
UPDATE REGIS INNER JOIN Combination ON REGIS.WATER_WELL = Combination.DHH_ID SET Combination.DNR_STATUS = [REGIS].[WELL_STATU]
WHERE (([Combination].[DNR_STATUS] Is Null));

I am afraid to try it.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I would recommend trying it on a test copy of your database, but I do see a potential problem:
Code:
UPDATE [COLOR=#ff0000][B]REGIS[/B][/COLOR]...
Code:
... SET [COLOR=#ff0000][B]Combination[/B][/COLOR].DNR_STATUS =...
So which table are you trying to update there? The REGIS table or the Combination table.
You see to have conflicting information there.
 
Upvote 0
it looks ok to me

but you can always do this first

Code:
select REGIS.*,  Combination.* from REGIS INNER JOIN Combination ON REGIS.WATER_WELL = Combination.DHH_ID 
WHERE (([Combination].[DNR_STATUS] Is Null));

then you can see what will get updated
 
Upvote 0
Thanks for the help. I changed it to a select query, made a few modifications to the query, got the results that I wanted, and then ran the update query.
Thanks again! :)
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,250
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top