SQL select 查询 - 如何将 blob 格式转换为文本

问题描述 投票:0回答:1

我有一个 SQL 选择查询,我从表中选择列,其中一些是 BLOB 格式。我想根据列是否为空(是否有数据)将 BLOB 列显示为“是”或“否”。

我尝试过使用此 case 语句,但无论该值是否为空,它总是返回“是”。我该如何解决这个问题?

select category,
description,
CASE maintenance
    when 1 then 'Yes'
    else 'No'
END maintenance,
submittedBy,
CASE image
    when NULL then 'No'
    else 'Yes'
END image
from Forms
sqlite
1个回答
0
投票

NULL
的值必须使用
IS
进行检查,因此将您的查询重写为

select category,
description,
CASE maintenance
    when 1 then 'Yes'
    else 'No'
END maintenance,
submittedBy,
CASE when image IS NULL then 'No'
    else 'Yes'
END image
from Forms
© www.soinside.com 2019 - 2024. All rights reserved.