0

How can i update two rows with one query in ms access...

I tested manny codes but noone worked for me...

UPDATE tblSecondProductItems 
SET secondProductItemLot = CASE
when secondProductItemCode = '616161911659' then 20
when secondProductItemCode = '611611965166' then 21
end
where secondProductItemCode in('616161911659','611611965166')
2
  • 2
    Can you elaborate on the problem this statement is causing? Does it error out? produce the wrong result? Commented Mar 2, 2017 at 13:13
  • It commes error: syntax error (missing operator) in query expression 'CASE when secondProductItemCode = '616161911659' then 20 when secondProductItemCode = '611611965166' then 21 end Commented Mar 2, 2017 at 13:13

2 Answers 2

1

MS Access doesn't support CASE. You can use SWITCH():

UPDATE tblSecondProductItems 
    SET secondProductItemLot = SWITCH(secondProductItemCode = '616161911659', 20,
                                      secondProductItemCode = '611611965166', 21
                                     )
    WHERE secondProductItemCode IN ('616161911659','611611965166')
Sign up to request clarification or add additional context in comments.

Comments

0

You can try something like

UPDATE tblSecondProductItems 
CASE
    when secondProductItemCode == '616161911659' then secondProductItemCode = 20
    when secondProductItemCode == '611611965166' then secondProductItemCode = 21
END
WHERE secondProductItemCode in('616161911659','611611965166')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.