mybatis做like模糊查询

 

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>

 

posted @ 2017-11-08 14:01  贩卖长江水  阅读(491)  评论(0编辑  收藏  举报