The following articles mainly describe the actual operation process of MySQL database return that affects the number of rows, we mainly introduce the specific operation steps of the application code when the MySQL database returns the affected number of rows. The following describes the main content of the article.
- found_rows() : select
- row_count() : update delete insert
Note: It must be used together with the corresponding operation. Otherwise, the returned values are only 1 and-1 (both incorrect values)
Example:
- 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();
Output 3 (the number of newly added records is returned). [Note: If insert into... values is used, only 1 is returned.]
- select * from `MyTestTable`;select found_rows();
Output 3 (return the selected number of rows)
- update `MyTestTable` set `Name`='people';select row_count();
Output 3 (the number of modified rows is returned)
- delete from `MyTestTable`;select row_count();
Output 3 (the number of rows to be deleted). The above content introduces the code that affects the number of rows returned by the MySQL database. I hope you will get some benefits.
The above content is the description of the Code that affects the number of rows returned by the MySQL database. I hope it will help you in this regard.