Hello guys,
I need help with a messed up update query I did today... I had the wrong approach on how to correctly use an update query, and I know now how to write it correctly, however there are about 53 total fields I need to re-write per query, and I have to do it for 3 different queries again.
Basically, what I did was (I will use a simple table structure and query):
Table1
ID a b c
1 s s s
2 d s d
3 g h s
example this is the table data that I have. what I want to do is update all "s" to 0, the query I wrote was:
and when I run this, every record updates to 0...
What I need though is only "s" updates to 0... so I now know that I should re-write the query as:
and this gives me the correct results that I need.
My question now though is that, is this the only way for me to write the query correctly? or are there any other options that I could choose to re-write 53 fields in 3 different queries?
I know that this was my stupid mistake and I take the blame for my logic error...
But any help is greatly appreciated...
I need help with a messed up update query I did today... I had the wrong approach on how to correctly use an update query, and I know now how to write it correctly, however there are about 53 total fields I need to re-write per query, and I have to do it for 3 different queries again.
Basically, what I did was (I will use a simple table structure and query):
Table1
ID a b c
1 s s s
2 d s d
3 g h s
example this is the table data that I have. what I want to do is update all "s" to 0, the query I wrote was:
Code:
UPDATE Table1 SET Table1.a = "0", Table1.b = "0", Table1.c = "0"
WHERE (((Table1.a)="s")) OR (((Table1.b)="s")) OR (((Table1.c)="s"));
and when I run this, every record updates to 0...
What I need though is only "s" updates to 0... so I now know that I should re-write the query as:
Code:
UPDATE Table1 SET Table1.a = IIf([Table1].[a]="s",0,[Table1].[a]), Table1.b = IIf([Table1].[b]="s",0,[Table1].[b]), Table1.c = IIf([Table1].[c]="s",0,[Table1].[c]);
and this gives me the correct results that I need.
My question now though is that, is this the only way for me to write the query correctly? or are there any other options that I could choose to re-write 53 fields in 3 different queries?
I know that this was my stupid mistake and I take the blame for my logic error...
But any help is greatly appreciated...