select * from tablename  where  a='b' and c='d'
当b不为空时a='b'才成为查询条件,请问怎么实现?
谢谢

解决方案 »

  1.   

    declare @aa varchar(20)
    select @aa=b from tablename 
    if @aa is not null
    bengin
    select * from tablename  where  a='b' and c='d'
    end
      

  2.   

    declare @aa varchar
    set @aa='b'--请问这里的b是怎么得到的?
    if @aa is not null
    bengin
    select * from tablename  where  a='b' and c='d'
    end
      

  3.   

    解决了
    我用的是ibatis<isNotNull prepend="and" property="tiku_cd">
    T02.TIKU_CD=#tiku_cd#
    </isNotNull>