我有以下生成的列修改,它给我抛出了一个错误。我最近使用类似的嵌套案例修改了它,但后来意识到我没有保存查询,并且我需要更新一项检查,因此需要更新它。
ALTER TABLE
`t1` MODIFY COLUMN `criteria` GENERATED ALWAYS AS(
CASE WHEN `status` = 'Active' THEN
CASE WHEN `exempt` = 'FALSE' AND `age` < 35 THEN
CASE WHEN `experience` = "Pro" AND `rule` = 'Descendent' THEN 6
WHEN `experience` = "Pro" AND `rule` != 'Descendent' THEN 5
WHEN `experience` = 'Division I' AND `rule` = 'Descendent' THEN 5
WHEN `experience` = 'Division I' AND `rule` != 'Descendent' THEN 4
WHEN `experience` = 'Division II' AND `rule` = 'Descendent' THEN 4
WHEN `experience` = 'Division II' AND `rule` != 'Descendent' THEN 3
WHEN `experience` = 'Division III' AND `rule` = 'Descendent' THEN 3
WHEN `experience` = 'Division III' AND `rule` != 'Descendent' THEN 2
WHEN `experience` = 'NAIA' AND `rule` = 'Descendent' THEN 3
WHEN `experience` = 'NAIA' AND `rule` != 'Descendent' THEN 2
WHEN `experience` = 'Junior College' AND `rule` = 'Descendent' THEN 2
WHEN `experience` = 'Junior College' AND `rule` != 'Descendent' THEN 1
WHEN `experience` = 'High School' AND `rule` = 'Descendent' THEN 1
ELSE 0
END
ELSE 0
END
ELSE 0
END
) STORED
谁能告诉我我在这里缺少什么?我一生都无法弄清楚我错过了什么。提前致谢! 这是来自 MySql 的错误:
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GENERATED ALWAYS AS(
CASE WHEN `status` = 'Active' THEN
CA' at line 2
即使对于生成的列,您也必须指定数据类型作为列定义的一部分。
ALTER TABLE
`t1` MODIFY COLUMN `criteria` _______________________ GENERATED ALWAYS AS ...
^ data type goes here ^