1. 程式人生 > >mybatis 模糊查詢

mybatis 模糊查詢

names sel concat earch result space ear ace res

<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>
and i.del=0 order by i.createtime desc
</select>

mybatis 模糊查詢