mybatis判断多个条件
以下是通过仓库+物资来进行查询
@Select("<script>" + "SELECT v.id,v.kfcode,v.kfname,v.kc, p.wzname,p.dw,v.wzgg" + " FROM (select * from y_kc" + " where softdel=0" + "<if test=\"kfcode!=null and kfcode!=''\">" + " and kfcode=#{kfcode}" + "</if>" + "<if test='wzbm!=null'>" + " and wzbm like concat('%',#{wzbm},'%') " + "</if>" + ") v inner join wz p" + " on v.wzbm=p.wzbm" + " order by v.wzbm asc" + "</script>") Page<Kc> getKcswithWz(IPage<Kc> page, @Param("wzbm") String wzbm, @Param("kfcode") String kfcode);
上面是使用转义符来处理是不是等于‘’来判断。
道法自然