我有一些年龄段,我试图根据年龄列中的值添加一列年龄段。我有一个age_range
列,我正在尝试这个:
UPDATE mytable
SET age_range =
CASE WHEN age >=1 and age <= 24 then '18-24'
ELSE ''
END AS age_range
FROM mytable
但是我收到了错误:
check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS age_range
FROM mytable' at line 5
我做错了什么?
答案 0 :(得分:3)
你不需要这个:
AS age_range
FROM mytable
试试这个
UPDATE mytable
SET age_range =
CASE WHEN age >=1 and age <= 24 then '18-24'
ELSE ''
END