1 2 3 4

mybatis 模糊查询

<mapper namespace="com.edc.dao.organize.OrganizeInfoMapper" > //对应相应的mapper.java文件

<select id="findBySearch" resultMap="BaseResultMap" parameterType="java.util.Map" >
    SELECT i.* FROM t_organize_info i,t_location_city ci,t_location_country co,t_location_province p
    WHERE i.provinceId=p.provinceId AND i.countryId=co.countryId AND i.cityId=ci.cityId
       <if test="region!=null and region!=''">
           and (co.countryName LIKE CONCAT(CONCAT('%', #{region}),'%')
           or p.provinceName LIKE CONCAT(CONCAT('%', #{region}),'%')
           or ci.cityName LIKE CONCAT(CONCAT('%', #{region}),'%'))   
    </if>
       <if test="organizename!=null and organizename!=''">
           and i.organizename LIKE CONCAT(CONCAT('%', #{organizename}),'%')   
    </if>  
    <if test="type!=null and type!=''">  
        AND i.type LIKE CONCAT(CONCAT('%', #{type}),'%')   
    </if>

<if test="searchendmoney!=null and searchendmoney!=''">
        <![CDATA[ AND Approved_num <  #{searchendmoney}]]>  // 代码块
    </if>
    and i.del=0 order by i.createtime desc
  </select>

posted @ 2017-05-16 09:59  一缕清风丶  阅读(482)  评论(2编辑  收藏  举报