如何判断sql中image字段是否为空,为空查询为1

时间:2022-10-14 04:55:36
如何写这样的查询,一个表中有个image的字段图像,但有null值
如何写查询 select 字段  from 表
使字段为null时显示为0,字段不为null时显示1谢谢

15 个解决方案

#1


select case when 字段 is null then 0 else 1 end from 表

#2


谢谢了

#3


 


select case when 字段 is null then 0 else 1 end from 表

#4


 

select case when 字段 is null then 0 else 1 end from 表

							     

#5


郁闷死啦。。为啥子我粘上去的SQL code 那么难看。。别个弄的都那么好看呢?那个高手给指点哈嘛

#6


[ c o de=SQL] 。。。
[/ c o d e]
是这样的

#7


select case when 字段 is null then 0 else 1 end from 表
来慢了,楼上的都说了~~~

#8


引用 5 楼 baiying15 的回复:
郁闷死啦。。为啥子我粘上去的SQL code 那么难看。。别个弄的都那么好看呢?那个高手给指点哈嘛

在回復里點有點像#的圖標,在中間放入你的代碼

#9


来迟了.哈哈.

#10



select case when image的字段 is null then 0 else 1 end from 表

#11


select case when 字段 is null then 0 else 1 end from 表


来晚了,还是回复下,混分

#12


isnull()

#13


isnull()

#14


up..................

#15


--测试不通过,全都是1
[code=select show= case 字段 when is null then 0 else 1 end from table]
[/code]

#1


select case when 字段 is null then 0 else 1 end from 表

#2


谢谢了

#3


 


select case when 字段 is null then 0 else 1 end from 表

#4


 

select case when 字段 is null then 0 else 1 end from 表

							     

#5


郁闷死啦。。为啥子我粘上去的SQL code 那么难看。。别个弄的都那么好看呢?那个高手给指点哈嘛

#6


[ c o de=SQL] 。。。
[/ c o d e]
是这样的

#7


select case when 字段 is null then 0 else 1 end from 表
来慢了,楼上的都说了~~~

#8


引用 5 楼 baiying15 的回复:
郁闷死啦。。为啥子我粘上去的SQL code 那么难看。。别个弄的都那么好看呢?那个高手给指点哈嘛

在回復里點有點像#的圖標,在中間放入你的代碼

#9


来迟了.哈哈.

#10



select case when image的字段 is null then 0 else 1 end from 表

#11


select case when 字段 is null then 0 else 1 end from 表


来晚了,还是回复下,混分

#12


isnull()

#13


isnull()

#14


up..................

#15


--测试不通过,全都是1
[code=select show= case 字段 when is null then 0 else 1 end from table]
[/code]