数据库有一张表incident 里面有字段priority
priority有值1,2,3,4如何将priority的值查询替换为紧急,高,中,低 但是priority实际值不变。只是在界面显示为紧急,高,中,低。
例如:priority priority 显示结果
1 紧急
2 高
3 中
4 低
select priority,
(case priority when 1 then '紧急' when 2 then '高' when 3 then '中' when 4 then '低' else '其他' end ) from incident
本文介绍了一种使用 SQL 的 case 语句来转换数据库表中的 priority 字段显示的方法,通过简单的 select 语句结合 case...when 结构,可以将数字形式的优先级转换为文字形式,如“紧急”、“高”、“中”和“低”,而不会改变原始数据。
1386

被折叠的 条评论
为什么被折叠?



