为什么此查询不起作用? (我试图替换嵌套的IF语句“… SET lkey = IF(lkey> = 11,lkey-5,IF(lkey> 5,lkey 2,lkey)
UPDATE pages SET lkey = CASE lkey WHEN lkey >= 11 THEN lkey - 5 ELSE CASE lkey WHEN lkey > 5 THEN lkey + 2 ELSE lkey END END,rkey = CASE lkey WHEN lkey >= 11 THEN rkey - 5 ELSE CASE rkey WHEN rkey < 11 THEN rkey + 2 ELSE rkey END END WHERE rkey > 5 AND lkey < 12;
在这个子句中的语法是错误的(和类似的)
原文链接:https://www.f2er.com/sqlite/198142.htmlCASE lkey WHEN lkey > 5 THEN lkey + 2 ELSE lkey END
这是
CASE WHEN [condition] THEN [expression] ELSE [expression] END
要么
CASE [expression] WHEN [value] THEN [expression] ELSE [expression] END
所以在你的情况下它会读:
CASE WHEN lkey > 5 THEN lkey + 2 ELSE lkey END
查看文档(CASE表达式):