如何使用sql
中的if语句检查多个条件在伪代码中
If survey_field is 1 and emp_code_field = 1 and post_field = 1 THEN set chance to 10
else if survey_field is 1 and emp_code_field = 1 THEN set chance to 5
survey_field is 1 THEN set chance to 1
我尝试过以下操作,但我无法使用多个条件。
Update employee
SET chance =
CASE survey
WHEN 1 THEN 1
END
WHERE 1
答案 0 :(得分:1)
你可以尝试这样..
UPDATE employee
SET chance = Case when
( survey_field=1) AND (emp_code_field = 1) AND (post_field = 1) THEN 10
ELSE
WHEN (survey_field =1) AND (emp_code_field = 1) THEN 5
ELSE
WHEN
survey_field = 1 THEN 1
END