关于mybatis的模糊查询

xiaoxiao2021-02-28  100

   之前以为自己得模糊查询写的不错,谁知水深的很,自己也就是个皮毛。

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

 <!-- 根据学历、年龄、月薪、行业类别、工作地区查询所有数据 --> <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>

转载请注明原文地址: https://www.6miu.com/read-21175.html

最新回复(0)