Current location - Training Enrollment Network - Mathematics courses - What is the function of calculating the cumulative sum of fields in SQL? What is the function of counting the quantity of goods? Does anyone know?
What is the function of calculating the cumulative sum of fields in SQL? What is the function of counting the quantity of goods? Does anyone know?
1. First, create a new test database, create a new type table in the database, and insert three test data into it.

2. Create a new php file, name it handle.php, and set the file code as utf8 and header. Handle.php is mainly used to connect the database and count the string length of the specified field in the type data table.

3. Then, in the handle.php file, use mysqli to connect to the database through the database name, account number and password.

4. Set the code of set_charset to get the data table as utf8, and use the if statement to prompt when the connection to the database fails.

5. Write an sql statement, count the string length of the type_name field by length () method, execute the sql statement by query, and finally convert the obtained data resources into a two-dimensional array by fetch_all method.

6. Finally, open the handle.php file in the browser and check the string length of the type_name field in the type data table, as shown in the following figure.