Solved Combine two identically structured update queries?

gojets1721

Registered User.
Local time
Today, 04:15
Joined
Jun 11, 2019
Messages
430
I have two update queries that update two fields in the same table to 'N/A' if the respective field is null.

Here they are:

Query 1:
Code:
UPDATE tblComplaints SET Location = "N/A"
WHERE Location Is Null;

Query 2:
Code:
UPDATE tblComplaints SET Category = "N/A"
WHERE Category Is Null;

For simplicity, it'd be nice to just combine these into one update query but idk if that's possible. I tried the below but it only updates the fields if both are null.

Code:
UPDATE tblComplaints SET Location = "N/A", Category = "N/A"
WHERE Location Is Null AND Category Is Null;

I then tried below but this one updates both even if only one of them is null.
Code:
UPDATE tblComplaints SET Location = "N/A", Category = "N/A"
WHERE Location Is Null OR Category Is Null;

Maybe it's just not possible. Curious your thoughts tho. Thanks!
 
Code:
UPDATE tblComplaints SET Location = Nz(Location, "N/A"), Category = Nz(Category, "N/A")
However, the two individual queries above make more sense.
 
What does "N/A" do for you that NULL doesn't?

How does NULL get in there? Why not disallow nulls at the table level?
 

Users who are viewing this thread

Back
Top Bottom