Mybatis学习日志二
一、动态sql 1、动态SQL:if 语句 <select id="selectUserByUsernameAndSex" resultType="user" parameterType="com.ys.po.User"> select * from user where <if test="username != null"> username=#{username} </if> <if test="username != null"> and sex=#{sex} </if> </select> 2、动态SQL:if+where 语句 <select id="selectUserByUsernameAndSex" resultType="user" parameterType="com.ys.po.User"> select * from user <where> <if test="username != null"> username=#{username} </if> <if test="username != null"> and sex=#{sex} </if> </where> </select> 3、动态SQL:if+set 语句 <!-- 根据 id 更新 user 表的数据 --> <update id="updateUserById"