数据表列的数据值 [英] data value of a data table column

查看:77
本文介绍了数据表列的数据值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我有一个带有2个数据表的SQL数据库.一个表具有一列,其类型为int.该列的值为1、2、3或4.在我的应用程序中,这些数字具有不同的含义,例如

Hello,
I have an SQL database with 2 data tables. One Table has a column which is of type int. The value of that column will be 1, 2, 3 or 4. In my application these numbers have different meanings like

1 - "Started"
4 - "End"
2- "Paused"
3 - "Restart"


目前,我正在读取列值为1,2,3等,并转换为相应的字符串.举例说,如果我将列值设为1,则我正在比较并将其转换为已开始".

有什么方法可以在数据表中显示与1,2,3或4相同的数据,并在检索时以开始"或暂停"之类的字符串形式获取输出?然后,我可以避免比较整数并实用地获取各个字符串.


Currently i am reading the column value as 1,2,3 etc and converting to respective strings. Say for example if i get column value as 1, i am comparing and converting it as "Started".

Is there any way to display the data same as 1,2,3 or 4 in data table and while retrieving, get the output as string like "Started" or "paused" ? Then i can avoid comparing the integers and getting respective strings pragmatically.

推荐答案


hi
选择查询中的用例语句.


选择状态=大小写,当1则开始",4时结束",当2然后"Pushed",3时再重启"结束
hi
use case statement in select query.


Select status = case when 1 then ''Started'' when 4 then ''end'' when 2 then ''Pushed'' when 3 then ''Restart'' end


这篇关于数据表列的数据值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆