关于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>
特在此记录一下,因为这个格式和以前自己写的、想的不一致。 特别要注意一下红体部分
<!-- 根据学历、年龄、月薪、行业类别、工作地区查询所有数据 -->
<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>
相关文章推荐
- 关于mybatis的模糊查询
- 【MyBatis】关于模糊查询的两种处理方法
- 关于mybatis中llike模糊查询中#和$的使用
- 关于mybatis的模糊查询
- 关于mybatis 模糊查询
- 关于Mybatis 中模糊查询查找不到Mysql数据库的内容的问题
- 关于Mybatis模糊查询出现的问题
- 关于 mybatis 的模糊查询
- Mybatis中like模糊查询
- Mybatis模糊查询
- 关于数据库中字段为日期的模糊查询问题
- Mybatis中模糊查询的各种写法
- Mybatis学习----模糊查询和动态sql
- Mybatis中oracle、mysql、db2、sql server的like模糊查询
- Mybatis中模糊查询
- mybatis模糊查询实现
- MyBatis模糊查询分页
- 关于PreparedStatement执行模糊查询
- 六、Mybatis动态SQL和模糊查询
- Mybatis中的模糊查询