当然可能,比如如下数据:
islot   lport
null     null
3        3
用第一、三条当然可以查出来,但第二条当然查不出来。

解决方案 »

  1.   

    当然可能,比如如下数据:
    islot   lport
    null     null
    3        3
    用第一、三条当然可以查出来,但第二条当然查不出来。
      

  2.   

    数据库里的值是lsname      lnname  lslot  lport
    珠三角环一  广州A    3      3select * from t1 where isnull(lsname,'') = '珠三角环一' and isnull(lnname,'') ='广州A' and isnull(lslot,'') = '' and isnull(lport,'') = '' 
    这条语句能查到结果select * from t1 where isnull(lsname,'') = '珠三角环一' and isnull(lnname,'') ='广州A' and isnull(lslot,'') = '3' and isnull(lport,'') = '' 
    为什么这条语句就不能查到结果?我不明白,请高手指点,谢谢
      

  3.   

    txlicenhe(马可&不做技术高手: 你好,语句
    select * from t1 where isnull(lsname,'') = '珠三角环一' and isnull(lnname,'') ='广州A' and isnull(lslot,'') = '' and isnull(lport,'') = '' 是可以查到 lslot and lport 都为3的结果,或者说可以查到所有lslot and lport 为空和不为空的结果
      

  4.   

    很正常啊,
    select * from t1 where isnull(lsname,'') = '珠三角环一' and isnull(lnname,'') ='广州A' and isnull(lslot,'') = '3' and isnull(lport,'') = '' 
    你沒有減少條件只是改變了條件的值
    isnull(lport,'') = '' 沒有這樣的記錄
      

  5.   

    那为什么
    select * from t1 where isnull(lsname,'') = '珠三角环一' and isnull(lnname,'') ='广州A' and isnull(lslot,'') = '' and isnull(lport,'') = '' 又可以查到所有的结果呢?select * from t1 where isnull(lsname,'') = '珠三角环一' and isnull(lnname,'') ='广州A' and isnull(lslot,'') = '3' and isnull(lport,'') = '' 
    是在原有的基础上进一步赛选而已,反而出不来
      

  6.   

    你的数据库里没有isnull(lslot,'')='3' 同时isnull(lport,'')=''的记录
      

  7.   

    我想如果我要在lport没有输入值的时候,选出所有 NULL or 任何值 并与前面的条件是 and 的语句,因该怎么写?
    谢谢
      

  8.   

    select * from t1 where isnull(lsname,'') = '珠三角环一' and isnull(lnname,'') ='广州A' and isnull(lslot,'') = '3' 
    and (isnull(lport,'') = '' or isnull(lport,'') <> '')
      

  9.   

    faint, if i have 30 conditions, whether i have to attach 30 "or isnull(xxx,'') "<> '') at the end of the sentence?
      

  10.   

    select * from t where (isnull(lsname,'') = '"&lsname &"' or isnull(lsname,'') <> '') and (isnull(lnname,'') ='"&lnname&"' or isnull(lnname,'') <> '') and (isnull(lslot,'') = '"&lslot&"'  or isnull(lslot,'') <> '') and (isnull(lport,'') = '"&lport&"'  or isnull(lport,'') <> '') 我才写了4个条件就发现问题了, 不论输入什么所有的数据都回出来