我已完成此更新脚本:
UPDATE etude
SET id_enseigne
(CASE WHEN id_enseigne= 1 THEN 6
ELSE CASE WHEN id_enseigne= 1 THEN 6
ELSE CASE WHEN id_enseigne= 2 THEN 26
ELSE CASE WHEN id_enseigne= 3 THEN 2122
ELSE CASE WHEN id_enseigne= 4 THEN 1960
ELSE CASE WHEN id_enseigne= 5 THEN 84
ELSE CASE WHEN id_enseigne= 6 THEN 103
ELSE CASE WHEN id_enseigne= 7 THEN 56
ELSE CASE WHEN id_enseigne= 8 THEN 108
ELSE CASE WHEN id_enseigne= 9 THEN 68
ELSE CASE WHEN id_enseigne= 10 THEN 489
ELSE CASE WHEN id_enseigne= 11 THEN 1124
ELSE CASE WHEN id_enseigne= 13 THEN 502
ELSE CASE WHEN id_enseigne= 14 THEN 1298
ELSE 0 END)
但是我得到了这个错误,我不明白为什么,因为它应该很简单:
ERROR: syntax error at or near "("
LINE 3: (CASE WHEN id_enseigne= 1 THEN 6
^
********** Erreur **********
ERROR: syntax error at or near "("
État SQL :42601
Caractère : 30
答案 0 :(得分:0)
另一个case
syntax更方便:
update etude
set id_enseigne = case id_enseigne
when 1 then 6
when 2 then 26
when 3 then 2122
when 4 then 1960
when 5 then 84
when 6 then 103
when 7 then 56
when 8 then 108
when 9 then 68
when 10 then 489
when 11 then 1124
when 13 then 502
when 14 then 1298
else 0
end