美文网首页
Mysql 使用注意

Mysql 使用注意

作者: 南岩飞雪 | 来源:发表于2018-07-21 13:58 被阅读0次

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

相关文章

  • 数据库

    • MySQL 索引使用的注意事项 MySQL 索引使用的注意事项 索引不会包含有NULL值的列使用短索引...

  • Mysql 使用注意

    Mysql中不等于过滤null 代码段1 没办法更新 NULL 数据, 需要使用代码段2 limit分页,数据重复...

  • 在linux下定时备份mysql数据库

    注意mysql版本,在mysql5.6版本之后使用明码的mysql密码会提示: Warning: Using a ...

  • docker安装mysql

    本次以mysql:8.0.29作为示例,注意不要使用最新版,容易出现不稳定的bug 使用mysql:8.0.29镜...

  • 索引(二)

    mysql索引的新手入门详解mysql索引之三:索引使用注意规则 索引(Index)是帮助 MySQL 高效获取数...

  • Swoft MySQL

    注意事项 要使用MySQL前提条件必须安装了MySQL,由于目前采用的是Docker的使用,所以提前需要使用Doc...

  • 云服务器wordpress搭建

    mysql的使用与选择 1.我是个人服务器,但是先使用了最新的mysql8做尝试,需要注意的是php与mysql8...

  • 使用Vagrant实践MySQL主从复制

    使用vagrant 启动两台server,并都安装mysql. 注意vagrant网络配置 mysql配置中bin...

  • 使用docker安装mysql

    第一步:使用docker pull 拉取docker hub仓库中mysql镜像 (注意备注) mysql镜像版本...

  • ES导入MySql数据

    1. logstash导入MySQL数据 要使用logstash导入数据的时候,首先需要将mysql的驱动包(注意...

网友评论

      本文标题:Mysql 使用注意

      本文链接:https://www.haomeiwen.com/subject/tujhmftx.html