Answer the question
In order to leave comments, you need to log in
How to do CASE WHEN THEN for multiple values?
Friends, a question on databases. Query that works:
UPDATE `col` SET
`nul` = CASE
WHEN (`attr1`,`attr2`) = ('param1','otv1') THEN '1'
WHEN (`attr1`,`attr2`) = ('param1','otv2') THEN '2'
WHEN (`attr1`,`attr2`) = ('param1','otv3') THEN '3'
END
WHERE (`attr1`,`attr2`) IN (('param1','otv1'),('param1','otv2'),('param1','otv3'))
nul = 1 if attr1 == param1 && attr2 == otv1
nul = 1 && bul = x if attr1 == param1 && attr2 == otv1
Answer the question
In order to leave comments, you need to log in
UPDATE `col` SET
`nul` = CASE
WHEN (`attr1`,`attr2`) = ('param1','otv1') THEN '1'
WHEN (`attr1`,`attr2`) = ('param1','otv2') THEN '2'
WHEN (`attr1`,`attr2`) = ('param1','otv3') THEN '3'
END,
`bul` = CASE
WHEN (`attr1`,`attr2`) = ('param1','otv1') THEN '1'
WHEN (`attr1`,`attr2`) = ('param1','otv2') THEN '2'
WHEN (`attr1`,`attr2`) = ('param1','otv3') THEN '3'
END
WHERE (`attr1`,`attr2`) IN (('param1','otv1'),('param1','otv2'),('param1','otv3'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question