Mybatis的sql语句编写问题

1、逻辑删除sql

  update contacts set status = '2' where id = #{id}

2、多条件更新sql

  update contacts
  <set>
  <if test="name != null">
   name = #{name},
  </if>
  <if test="phone != null">
  phone = #{phone}
  </if>
  </set>
  where id = #{id}

3、多条件查询sql

  select * from contacts where id = #{id} and status = '1'

  

猜你喜欢

转载自www.cnblogs.com/hy-smart/p/12710208.html