Detailed introduction to affected rows

Source: Internet
Author: User
Tags mysql update
How can I use the SQL aggregate function to obtain the number of affected rows for addition, deletion, and modification? It is usually very useful to calculate the number of rows returned or affected by a query before performing further operations. This function is especially convenient when you want to display results on pages or generate statistics, how does one obtain the affected number of rows? 1. COUNT is used to COUNT the number of results in the next ten days. COUNT returns the number of rows in a query or partial query, which is usually used with DINSTINCT. SQL aggregate function COUNT is widely supported by a variety of databases! 2. how can I use the SQL aggregate function to obtain the number of affected rows for addition, deletion, and modification? It is usually very useful to calculate the number of rows returned or affected by a query before performing further operations. This function is especially convenient when you want to display results on pages or generate statistics, how does one obtain the affected number of rows? 1. COUNT is used to COUNT the number of results in the next ten days. COUNT returns the number of rows in a query or partial query, which is usually used with DINSTINCT. SQL aggregate function COUNT is widely supported by a variety of databases! 2. use the PDOStatement-> rowCount () method to return the affected rows PDOStatement-> rowCount () to obtain the number of rows affected by the UPDATE, INSERT, or DELECTE query. The rowCount () method is not common in typical PHP applications, but it can count the number of rows affected after calling PDOStatement-> execute. III. SQL aggregate function CO

1. how can I use the SQL aggregate function to obtain the number of affected rows for addition, deletion, and modification?

Description: The exec () method returns the number of affected rows after execution. The syntax is as follows: int PDO: exec (string statement). The statement parameter is the SQL statement to be executed. This method returns the number of affected rows during query execution. it is usually used in INSERT, DELETE, and UPDATE statements. For example: $ dbms = 'mysql'; // database Type $ dbName = 'admin'; // database used $ us

4. After SQL is added, the affected row of data is returned.

Description: the Inserted table is used to store copies of rows affected by INSERT and UPDATE statements. In an insert or update transaction, the new row is added to both the inserted table and the trigger table.

[Related Q & A recommendations ]:

Php obtains mysql update results

When php uses sp_executesql to perform the insert operation,-1 is successfully returned, and no affected rows are returned. how can we return the affected rows?

The above is a detailed description of the number of affected rows. For more information, see other related articles in the first PHP community!

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.