SQLite,将值1和0转换为读取和不读取的值

时间:2014-09-10 09:14:13

标签: sqlite

我有一个表,其中一列(称为origin)包含值1和0。

是否可以在sqlite中创建一个查询来动态转换这些值? 从表中选择原点(将1转换为读取,0转换为未读取)?

提前完成。

筛板

2 个答案:

答案 0 :(得分:1)

select case when origin = 1 
            then 'read'
            else 'not read'
       end as origin
from your_table

答案 1 :(得分:0)

使用CASE expression

可以实现这一点
SELECT CASE origin
       WHEN 1 THEN 'read'
       WHEN 0 THEN 'not read'
       ELSE        'whatever'  -- optional
       END
FROM MyTable
相关问题