where ((fld=v1 and v1 is not null) or (v1 is null and 'a'='a'))

解决方案 »

  1.   

    你是想输入条件然后组装sql语句,不知对否?
    我觉得简单点的方法就是用两个sql语句 
    if ( cond is null )
     sqlstmt = select * from table where col like 'cond%'
    else
     sqlstmt = select * from table
      

  2.   

    用orselect * from yourtable where (field is null or field=somevalue);
      

  3.   

    or
    select * from table where col like 'cond%' or (col is null and cond='')
      

  4.   

    sorry
    是 select * from yourtable where (somevalue is null or field=somevalue);