首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请问 自定义列 怎么替换Null

2012-01-30 
请教 自定义列 如何替换Null ?select*,(select type from tableB where tableA.id tableB.id)from table

请教 自定义列 如何替换Null ?

select 
*,(select type from tableB where tableA.id = tableB.id)
from tableA


1NULL
0NULL
0周末
0NULL


请教如何将Null批量成别的字符串呢?



select 
*,(select case when type is Null then '空字符串' else then type end from tableB where tableA.id = tableB.id)
from tableA

这样也不行,因为内查询没有查询到数据,
将case 放到最外边,总是报错.

[解决办法]
ISNULL(col,'aa')
[解决办法]

SQL code
select  *,(select isnull(type,'你想要的字符串') from tableB where tableA.id = tableB.id)from tableA
[解决办法]
SQL code
select  *,(select isnull(type,'别的字符') from tableB where tableA.id = tableB.id)from tableA 

热点排行