A 表左联B 表,B表中没有数据,返回的记录如下:
       name1  name2   name3
k  0   null   null    null
a  1   1.26   2.26     1根据 name1,name2,name3的值做判断,如果这三项没有值则不显示该条记录,即上面的这两条记录应只显示第二条:
a  1  1.26    2.26    1
记录绑定在grid上,应该怎么处理?

解决方案 »

  1.   

    WHERE 1=1 AND B.name1 <> null  AND B.name2 <> null  AND B.name3 <> null 
      

  2.   


    SELECT * 
    FROM a
    LEFT JOIN b
    ON  a.id = b.id
    WHERE ISNULL(name1, '')+ISNULL(name2, '')+ISNULL(name3, '')<>''
      

  3.   

    where name1 is not null and name2 is not null and name3 is not null
      

  4.   


    WHERE  B.name1 is not null  AND B.name2  is not null  AND B.name3  is not null 
      

  5.   

    where B.name1 is not null  AND B.name2  is not null  AND B.name3  is not null 
      

  6.   

    A表的字段name1是通过实际的表计算得出的:
    select RES3 .生産 as name1 ,RES3 .材料 as name2 ,RES3 .name1 /RES2 .name as name3
    from t
    left join 
    (select sum(a) as 生産,sum(b)as 材料 from t ) as res3
    left join 
    (select j as name from t ) as res2
    where。
    name1,name2,name3 的值不为null,怎么写
      

  7.   


    select * from
    (select RES3 .生産 as name1 ,RES3 .材料 as name2 ,RES3.name1 /RES2.name as name3
    from t
    left join  
    (select sum(a) as 生産,sum(b)as 材料 from t ) as res3
    left join  
    (select j as name from t ) as res2)a
    where name1 is not null and name2 is not null and name3 is not null
      

  8.   

    不用左联接,用内联接就不会出来.如果用左联接
    where 中加条件
     and (name1 is not null or name2 is not null or name3 is not null)
      

  9.   

    这是一个非常麻烦的sql语句,我就把大概意思写出来了,具体的关联条件没写。
    我试过在主表的where条件中加name1 is not null ,提示错误:name1不识别。
    现在除了8楼的方法还有没有别的,在关联的表中(RES3、RES2)加条件name1 is not null 行不行,会不会対结果造成影响
      

  10.   

    个人建议:
    你将需求,相关的表贴出来,大家帮你分析.有什么地方时可以优化的.select RES3 .生産 as name1 ,RES3 .材料 as name2 ,RES3 .name1 /RES2 .name as name3
    from t
    left join  (select sum(a) as 生産,sum(b) as 材料 from t ) as res3
    left join  (select j as name from t ) as res2
    where a is not null and b is not null and j is not nullt表中的a,b,j值不能够为空
    res3: a,b求和,
    res2: j,不显示为空的值
    如果a,b,j为空
    sum(a)=null
    sum(b)=null
    j=nullnull的算术运算都为空
      

  11.   


    name1不识别是由sql语句执行循序所决定的, 你用它的源名称再试试, 
    where RES3.生产 is not null, RES3.材料 is not null....