日期:2014-05-20  浏览次数:20426 次

SQL中的空值问题 帮帮忙 谢谢
比如表   A
      ID   学生
        1     A
        2     NULL
现在要这样   select   ID,学生   from   A  
但要这样显示   ID   学生
                          1       A
                          2        
就这样   比如学生为空的话   就什么都不显示   不是显示出NULL来

------解决方案--------------------
Selecte id , student From A where student <> null
------解决方案--------------------
select ID,nullif(学生, ' ') from A
------解决方案--------------------
不行就用这个:
for(int i = 0;i <dgrdxxx.Items.Count;i++)
{
if(this.dgrdxxx.Items[i].Cells[0].Text == "NULL ")
{
this.dgrdxxx.Items[i].Cells[0].Text = " ";
}

}
------解决方案--------------------
select ID,学生 from A where 学生 is not null
------解决方案--------------------
是用IsNull函数吧:
select id, IsNull(学生, ' ') --当是NULL的时候用空字符表示
form A


------解决方案--------------------
select id, IsNull(学生, ' ') --当是NULL的时候用空字符表示
form A


------解决方案--------------------
where(olereader.reader()){
dr=dt.newRow();
string s=olereader.getstring(0).tostring().trim();
if(s== " ")
dr[0]=s;
dt.rows.add(dr);
}
ds.tables.add(dt);
this.dg.datasource=ds.tables[ "biao "].DefaultView;
dg.databind;
------解决方案--------------------
原来是一个贴子啊,呵呵,
如果score是小数类型且显示为字符串,那么如下:

select cast(isnull(score,0.0) as varchar(10)) as score from A
------解决方案--------------------
select id, 学生=IsNull(学生, ' ') form A
------解决方案--------------------
select isnull(score,0.0) as score from A ,这个试试