select a.field1,a.field2 from
table1 a,table2 b
where a.customid=b.customid
and
(case when b.field3 is not null then  a.field3=b.field3 else b.field3 is null end)

解决方案 »

  1.   

    select a.field1,a.field2 from
    table1 a,table2 b
    where a.customid=b.customid
    and b.field3 is null
    union 
    select a.field1,a.field2 from
    table1 a,table2 b
    where a.customid=b.customid and a.field3=b.field3 
    and b.field3 is not null
      

  2.   

    zlp:
    (case when b.field3 is not null then  a.field3=b.field3 else b.field3 is null end)
    的等于附近有错误