Update query with multiple criteria and conditions (1 Viewer)

Moktar

New member
Local time
Today, 07:31
Joined
Apr 14, 2020
Messages
6
hello guys! need some help please
i have a table on Microsoft access and i would like to use update query to update a column. but instead of creating so many queries i want it to be one query.
i tried to do it like the query below but it didn't work. can anyone help please?

UPDATE vouchers SET vouchers.[InsuranceName ] = "CHPW"
WHERE (((vouchers.PAYOR)="MCR MCO") AND ((vouchers.Insurance_name) Like "**CHPW**"));
UPDATE vouchers SET vouchers_.[InsuranceName] = "Amerigroup"
WHERE (((vouchers.PAYOR)="MCR MCO") AND ((vouchers.Insurance_name) Like "**Amerigroup**"));
 

plog

Banishment Pending
Local time
Today, 09:31
Joined
May 11, 2011
Messages
11,613
You move the individual criteria to the SET using an Iif :


UPDATE vouchers
SET InsuranceName=Iif(Insurance_name Like "**CHPW**", "CHPW", Iif(Insurance_name Like "**Amerigroup**", "Amerigroup", InsuranceName), InsuranceName)
WHERE PAYOR="MCR MCO";
 

Moktar

New member
Local time
Today, 07:31
Joined
Apr 14, 2020
Messages
6
You move the individual criteria to the SET using an Iif :


UPDATE vouchers
SET InsuranceName=Iif(Insurance_name Like "**CHPW**", "CHPW", Iif(Insurance_name Like "**Amerigroup**", "Amerigroup", InsuranceName), InsuranceName)
WHERE PAYOR="MCR MCO";
I appreciate your time! but it didn't work :(
 

plog

Banishment Pending
Local time
Today, 09:31
Joined
May 11, 2011
Messages
11,613
I free handed it. The idea is sound, make the SQL work.
 

Users who are viewing this thread

Top Bottom