AND t.company_id = #{comp..._clickhouse where 1=1">
赞
踩
当需要实现可多选条件查询时,我们就要在查询语句中应用WHERE 1=1,这条语句可以简化sql查询的复杂度。
如果不添加1=1的判定,在执行到每个判定时,程序都需要往前找是否存在WHERE(?)
- WHERE 1=1
- <if test="companyId != null and companyId != ''">
- AND t.company_id = #{companyId}
- </if>
- <if test="tenderNo != null and tenderNo != ''">
- AND t.tender_no = #{tenderNo}
- </if>
- <if test="bidderCompanyId != null and bidderCompanyId != ''">
- AND tb.bidder_company_id = #{bidderCompanyId}
- </if>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。