开发者

SQL: show description in text instead of bit value

I have an attribute declared as bit: (true or false).

For example:

SELECT myBit FROM [table] 

=> it will show: 1 or 0

I would like to show: 'Valid' and 'Invalid' for 1 and 0 r开发者_JAVA百科espectively.

How could I add IF ELSE statement in the SELECT statement?


For SQL Server, you can use a CASE statement:

SELECT CASE myBit WHEN 1 THEN 'Valid' WHEN 0 THEN 'Invalid' END As MyColumn
FROM [table] 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜