MySQL数据库返回影响行数的实际操作流程
以下的文章主要是向大家描述的是MySQL数据库返回影响行数的实际操作流程,我们主要是以介绍MySQL数据库返回影响行数的时机应用代码来引出其具体的操作步骤,下面就是文章的主要内容描述。
- found_rows() : select
- row_count() : update delete insert
注:需要配合相应的操作一起使用,否则返回的值只是1和-1(都是不正确的值)
示例:
- drop database if exists `mytest`;
create database `mytest`;use `mytest`;
drop table if exists `MyTestTable`;
create table `MyTestTable`(`ID` int ,`Name` varchar(10));
insert into `MyTestTable`(`ID`,`Name`) select '1','role1'
union all select '2','role2' union all select '3','role3';select row_count();
输出3(返回新添加的记录数),[注:如果使用insert into...values只返回1]
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步