sql mybatis

来源:互联网 发布:淘宝网美国大樱桃 编辑:程序博客网 时间:2024/05/29 14:26
<select id="selectStudentByCondition" resultType="Student">
select * from student where name like '%' #{namecon} '%' and age>#{agecon}
</select>
<select id="selectStudentByCondition2" resultType="Student">
select * from student where name like '%' #{0} '%' and age>#{1}
</select>
<select id="selectStudentByMap" resultType="Student">
select * from student where name like '%' #{nameCondition} '%'
and age> #{ageCondition}
</select>
<select id="selectStudentByConditions" resultType="Student">
select * from student where name like '%' #{0} '%' and age > #{1}
</select>
<select id="selectStudentIf" resultType="Student">
select * from student where 1=1
<if test="name !=null and name!=''">
and name like '%' #{name} '%'
</if>
<if test="age > 0">
    and age > #{age}
</if>
</select>
<select id="selectStudentWhere" resultType="Student">
select * from student
<where>
<if test="name!=null and name!=''">
and name like '%' #{name} '%'
</if>
<if test="age>0">
and age>#{age}
</if>
</where>
</select>
原创粉丝点击