这是我的表格数据:
id | days
-----------
1 | 10
2 | 20
3 | 30
4 | 25
5 | 5
我想要这样的结果:
id days resultcolumn
1 10 less than 10
2 20 less than 20
3 30 less than 30
4 25 less than 30
5 5 less than 10
我使用了以下查询:
SELECT id,days,
CASE days
WHEN days<=10 THEN 'less than 10'
WHEN days<=20 THEN 'less than 20'
WHEN days<=30 THEN 'less than 30'
END AS 'days2'
FROM calender
但我得到了这样的结果数据:
id days resultcolumn
1 10 {null}
2 20 {null}
3 30 {null}
4 25 {null}
5 5 {null}
如何使用CASE
MySQL 中的语句获得原始结果?