Mysql中不等于过滤null
代码段1 没办法更新 NULL 数据, 需要使用代码段2
<update id="updateConfigStep">
update xxx set config_step=#{configStep}
where corp_id=#{corpId} and group_id=#{salaryGroupId} and config_step!='done'
</update>
<update id="updateConfigStep">
update xxx set config_step=#{configStep}
where corp_id=#{corpId} and group_id=#{salaryGroupId} and( config_step is null or config_step!='done')
</update>
limit分页,数据重复
使用 limit 分页取数据,需要指定 order by 唯一键;不然每次Mysql返回的数据顺序不一致,导致分页后取的数据重复/缺失
limit #{startRow}, #{pageSize} order by uid
If multiple rows have identical values in the ORDER BY columns, the server is free to return those rows in any order, and may do so differently depending on the overall execution plan. In other words, the sort order of those rows is nondeterministic with respect to the nonordered columns.
One factor that affects the execution plan is LIMIT, so an ORDER BY query with and without LIMIT may return rows in different orders.
https://dev.mysql.com/doc/refman/5.7/en/limit-optimization.html
网友评论