mapper中查询语句 where 后条件全都可以为null的时候怎么办? 待解决


select

from os_biz_sec_waf_instance obw
where

obw.CUSTOMER_ID=#{customerId}


AND obw.IS_DELETE=#{isDelete}


AND obw.DESCRIPTION LIKE CONCAT(CONCAT(’%’,#{description}),’%’)


AND obw.ID=#{id,jdbcType=VARCHAR}


AND obw.PROPOSER = #{proposer}


AND obw.STATUS=#{status}

ORDER BY obw.CREATED_TIME DESC

${limitString}

where

obw.CUSTOMER_ID=#{customerId}

这一行如果加上and,异常,如果不加and,并且传入null也会报错。如果查询条件可以全部为空的时候,怎么写?

猜你喜欢

转载自blog.csdn.net/weixin_42844971/article/details/86526921