当我们需要对MySQL数据库中的数据进行批量更新时,可以采用以下方式进行更新,以下为mybatis配置的SQL语句
update table_name
when id=#{cus.id} then #{cus.detailStatus}
when id=#{cus.id} then #{cus.errorJson}
when id=#{cus.id} then #{cus.changeContent}
when id=#{cus.id} then #{cus.updateTime}
when id=#{cus.id} then #{cus.yn}
id = #{cus.id}
以下是批量插入的SQL语句
INSERT INTO print_transbill (dept_no, dept_name, create_user, create_time, update_user, update_time,
transbill_code, box_num_start, box_num_end, box_print_status, print_type, ts, yn)
VALUES
(#{printPo.deptNo,jdbcType=VARCHAR}, #{printPo.deptName,jdbcType=VARCHAR}, #{printPo.createUser,jdbcType=VARCHAR},
#{printPo.createTime,jdbcType=TIMESTAMP}, #{printPo.updateUser,jdbcType=VARCHAR}, #{printPo.updateTime,jdbcType=TIMESTAMP},
#{printPo.transbillCode,jdbcType=VARCHAR}, #{printPo.boxNumStart,jdbcType=VARCHAR}, #{printPo.boxNumEnd,jdbcType=VARCHAR},
#{printPo.boxPrintStatus,jdbcType=VARCHAR}, #{printPo.printType,jdbcType=VARCHAR}, now(), 1)