我正在尝试选择一个整数字段作为文本,但我不知道该怎么做。
1
代表low
,2
代表medium
,3
代表hi
。
答案 0 :(得分:3)
您可以使用CASE WHEN
SELECT (CASE WHEN column = 1 THEN "low"
WHEN column = 2 THEN "medium"
WHEN column = 3 THEN "high"
END) AS value
FROM table_name;
答案 1 :(得分:2)
SELECT CASE intfield
WHEN 1 THEN 'low'
WHEN 2 THEN 'medium'
WHEN 3 THEN 'hi'
END AS inttext
FROM table
答案 2 :(得分:2)
Select
CASE WHEN field = 1 then 'low'
WHEN field = 2 then 'medium'
WHEN field = 3 then 'hi'
END as Col
from yourtable;