MySQL database returns the actual operation flow that affects the number of rows

Source: Internet
Author: User
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 (): selectrow_count (): updatedeleteinsert note:

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 (): updatedeleteinsert note:

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', 'Role 1'
Union all select '2', 'Role 2' union all select '3', 'Role 3'; 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.