我有一个 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
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