您的位置:首页 > 其它

关于mybatis的模糊查询

2017-08-05 12:08 316 查看
   之前以为自己得模糊查询写的不错,谁知水深的很,自己也就是个皮毛。

特在此记录一下,因为这个格式和以前自己写的、想的不一致。 特别要注意一下红体部分

 <!-- 根据学历、年龄、月薪、行业类别、工作地区查询所有数据 -->
<select id="findAllDataByKeyword" resultType="stationBean" parameterType="StationBean">
select
    <include refid="Base_Column_List" /> 
from station t1, company c
where 1=1 and t1.company_id=c.id 
<if test="education!=''"><if test="education!=null"> and t1.education=#{education}</if></if>
<if test="age_range!=''"><if test="age_range!=null"> and t1.age_range=#{age_range}</if></if>
<if test="wages!=''"><if test="wages!=null"> and t1.wages=#{wages}</if></if>
<if test="type!=''"><if test="type!=null"> and t1.type=#{type}</if></if>
<if test="working_area!=''"><if test="working_area!=null"> and t1.working_area=#{working_area}</if></if>
<if test="name !='' "><if test=" name !=null "> and t1.name like
"%"#{name}"%"
and c.name like "%"#{name}"%"
 </if></if>
</select>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: