1.like用于模糊查找 car_type like #{carType}
<!-- 查找 --> <select id="selectBylikes" resultMap="BaseResultMap" parameterType="java.util.Map"> select * from carinfo <where> <if test="carType!=null"> car_type like #{carType} </if> <if test="carColor!=null"> car_color like #{carColor} </if> </where> </select>
2.更新 car_type = #{carType},
<!-- 更新 --> <update id="updateField" parameterType="java.lang.Long"> update carinfo <set> <if test="carType!=null"> car_type = #{carType}, </if> <if test="carColor!=null"> car_color = #{carColor}, </if> </set> where id=#{id} </update>