我的表中有一个状态列,其中包含 int 值。如何为 int 赋值,或者我是否必须在表中创建一个新列?
我已经尝试过 ALTER table 但最好的方法是什么?
select status from table1;
如果我运行上面的查询,我们得到 -
id status
1 1
2 2
3 1
4 5
我想得到输出-
id status
1 Accepted
2 Completed
3 Accepted
4 Declined
最佳答案
使用 case expression , 邮政系统
select status,
case
when status=1 then 'Accepted'
when status=2 then 'Completed'
when status=3 then 'Accepted'
when sttaus=4 then 'Declined'
end mystatus
from table1;
关于sql - 如何将新列添加到具有与同一个表对应的值的表中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55492393/