zoukankan      html  css  js  c++  java
  • 当 LAST_INSERT_ID() 带有参数时# 清空重来

    [root@yejr.me]> truncate table t;

    # 插入1条新记录
    [root@yejr.me]> insert into t select 0,rand()*1024;

    # 查看 last_insert_id(), 符合预期
    [root@yejr.me]> select last_insert_id();
    +------------------+
    | last_insert_id() |
    +------------------+
    | 1 |
    +------------------+

    [root@yejr.me]> select * from t;
    +----+-----+
    | id | c1 |
    +----+-----+
    | 1 | 730 |
    +----+-----+

    # 调用 last_insert_id() 时增加表达式
    [root@yejr.me]> select last_insert_id(id+2) from t;
    +----------------------+
    | last_insert_id(id+2) |
    +----------------------+
    | 3 |
    +----------------------+

    # 再看 last_insert_id() 的值,好像“又不符合预期”了
    [root@yejr.me]> select last_insert_id();
    +------------------+
    | last_insert_id() |
    +------------------+
    | 3 |
    +------------------+

    # 插入1条新纪录
    [root@yejr.me]> insert into t select 0,rand()*1024;

    # 再看 last_insert_id() 的值,好像“又回到正轨”了
    [root@yejr.me]> select last_insert_id();
    +------------------+
    | last_insert_id(http://www.amjmh.com) |
    +------------------+
    | 2 |
    +------------------+

    [root@yejr.me]> select * from t;
    +----+-----+
    | id | c1 |
    +----+-----+
    | 1 | 730 |
    | 2 | 600 |
    +----+-----+
    2 rows in set (0.00 sec)

  • 相关阅读:
    linux中断子系统
    注释规范
    linux下C获取文件的大小
    oracle 11g 修改内存示例
    联想system sr650安装windows
    iphone 手机音乐制作
    canon dpp 编辑相机raw软件
    浪潮nf5270m5 安装2012
    三种刻录工具及用法
    centos7.5 连接存储配置iscsi
  • 原文地址:https://www.cnblogs.com/ly570/p/11448345.html
Copyright © 2011-2022 走看看