当 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)
最新文章
- STC12C5A60S2笔记3(I/O 端口)
- [bzoj4552][Tjoi2016][Heoi2016]排序
- 转载_虚拟机下LInux(终端)配置网络的方法
- git merge 与 rebase 的区别
- Find Minimum in Rotated Sorted Array
- vs2013的asp.net 管理
- EF Code First 更新数据库, 数据库迁移
- 如何解决WebkitBrowser使用出错“Failed to initialize activation context”
- codeforces 442C C. Artem and Array(有深度的模拟)
- 大数据技术 —— MapReduce 简介
- 配置OpenGL及第一个实例
- luogu P2580 于是他错误的点名开始了
- Adobe After Effects 2017-14.0安装教程
- oracle 行转列 列转行
- [Nodejs] node实现静态文件服务器
- dede二级导航
- 16 python 初学(生成器)
- Centos7 nginx提示错误 Access denied.
- Microsoft Visual Studio Community 2017 修改新建项目的默认位置
- C++提供的四种新式转换--const_cast dynamic_cast reinterpret_cast static_cast
热门文章
- ionic 提示 Error: Could not find gradle wrapper within Android SDK.
- 埋在 MYSQL 数据库应用中的17个关键问题!
- sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1091, ";Can't DROP 'users_ibfk_1'; check that column/key exists";) [SQL: ALTER TABLE users DROP FOREIGN KEY users_ibfk_1]
- 简单易用的字符串模糊匹配库Fuzzywuzzy
- 多线程编程-- part 4 线程间的通信
- 常用的商业级和免费开源Web漏洞扫描工具
- Ubuntu 18.04 LTS 64位Linux搭建Kubernetes 1.15.3并join子节点的完整过程
- Clob类型转换为String
- docker常用命令与容器创建
- 文件hash、上传,实现文件上传重复验证