torlee 发表于 2016-11-25 01:54:21

Mybatis学习第一天

<select id="selectUser" parameterType="User" resultType="User">
select * from user
<where>
<if test="id!=0">
id = #{id}
</if>
<if test="name!=null">
andname like '%'||#{name}||'%'
</if>
</where>
</select>
  
 其中,and是必须写的,如果id为0的时候,mybatis会自动将“and”过滤。
页: [1]
查看完整版本: Mybatis学习第一天