我有一个数据库表,某一个字段是查询条件字段,该字段有的是空格,有的是Null,有的是真正的记录。怎么筛选出来该字段不是空格的,并且不是null的记录。假设该字段为nameselect * from mytable where name is not null and 该字段没有空格。

解决方案 »

  1.   

    select * from mytable where name<>' '
      

  2.   

    select * from mytable where rtrim(isnull(name,''))!=''
      

  3.   

    select * from mytable where name is not null and name not like '% %'
      

  4.   

    declare @t table (id varchar(10))
    insert into @t 
    select '1' union all
    select '   ' union all
    select null union all
    select '2'select * from @t/*
    id
    ----------
    1
         --此处为空格
    NULL
    2(4 行受影响)*/
    select * from @t where id<>' '
    /*
    id
    ----------
    1
    2(2 行受影响)*/
      

  5.   

    select * from mytable where rtrim(isnull(name,''))!=''
      

  6.   

    select * from mytable where rtrim(isnull(name,''))!=''
      

  7.   

    select * from mytable where rtrim(isnull(name,''))!=''
      

  8.   


    select * from mytable where len(isnull(name,''))>0
      

  9.   


    select * from mytable where isnull(name,'') <> ''
      

  10.   

    select * from mytable where name>''
      

  11.   

    select * from mytable where name>''
      

  12.   

    select * from TableName where RTRIM(LTRIM(ISNULL(id,'')))<>''
      

  13.   

    ERE ISNULL(name,'')<>'' 梁哥的
      

  14.   

    select * from mytable where  isnull(name,'')<>''
      

  15.   


    WHERE ISNULL(name,'')<>''
      

  16.   

    where instr(name,1,' ')>0
      

  17.   

    select * from mytable where isnull(name,'')<>''
      

  18.   


    len(ltrim('')) <> 0