查询结果如下:
id m1 m2 m3 m4    m5 
01 15 2  7  null  null
02 15 4  3  5     2
03 1  5  7  33  null要求得到:
02 15 12 3  5   2
03 1  5  7  33  null把M4,M5都为NULL的排除

解决方案 »

  1.   

    select * from [table] where m4 is not null and m5 is not null
      

  2.   

    declare @T table(id varchar(5),m1 int,m2 int,m3 int,m4 int,m5 int)
    insert into @T select '01',15,2,7,null,null
    union all select '02',15,4,3,5,2
    union all select '03',1,5,7,33,null
     select * from @Tselect * from @T where m4 is not null or m5 is not null
      

  3.   

    select * from tb where m4 is not null and m5 is not null
      

  4.   

    用子查询好了
    SELECT * FROM (你第一个结果的查询语句) 
    WHERE  m4 IS NOT NULL AND m5 IS NOT NULL 
      

  5.   

    M4 is not null or M5 is not null
    或用
    isnull
      

  6.   

    满足两个条件时用
    M4 is not null and M5 is not null 
    --
    M4,M5为字符时可用
    isnull(M4,'')+isnull(M5,'')>''