求一条SQL 语句 找ic管理软件
库存管理软件版1楼: 有一个字段 content varchar(20)
它的值允许为空,现在假如content的值为
001
002
001
空
空
001
空
002
....
现在我想做这些一个查询
我想查找记录里面所有( content=''001'' or content='''' )
select content from tt
where (content=''001'' or content='''' )
但我想显示记录时,把content=''''的也显示为 ''0001''
这个功能,能不能就行SQL语句解决的,这个问题真的很麻烦
它的值允许为空,现在假如content的值为
001
002
001
空
空
001
空
002
....
现在我想做这些一个查询
我想查找记录里面所有( content=''001'' or content='''' )
select content from tt
where (content=''001'' or content='''' )
但我想显示记录时,把content=''''的也显示为 ''0001''
这个功能,能不能就行SQL语句解决的,这个问题真的很麻烦
2楼: 很简单的,select if(content='''',''0001'',content) content
from tt
where (content=''001'' or content='''' ) 如ic管理软件
3楼: select case when content='''' then ''001'' else content end as content
from tt
where (content=''001'' or content='''' )
4楼: select ''001'' as content
from tt
where (content=''001'' or content='''' )
这种方法更简单
5楼: 谢谢大家,你去试一下
6楼: select if(content='''',''0001'',content) content
from tt
where (content=''001'' or content='''' )
huo!
select if(content='''',''0001'',content) content
from tt
where (content=''001)'' or (content is Null)
库存管理软件版7楼: select ISNULL(content,''001'') content
from tt
where ISNULL(content,''001'') = ''001''
8楼: 问题解决了