MySQL database technology (36) [group chart] _ MySQL

Source: Internet
Author: User
MySQL database technology (36) [Photo] 6.8 Other topics

This section contains several topics that are not fully applicable to any section in the development of this chapter from client1 to client5:

■ Use the result set metadata to help verify that the data is suitable for calculation.

■ It is difficult to insert data into the query.

■ How to process graphic data.

■ How to obtain table structure information.

■ Common MySQL program design errors and how to avoid them.

6.8.1 perform computation on the result set

So far, we have concentrated and mainly used the result set meta data to print row data, but it is obvious that in addition to printing, there is also a need to use data to do other things. For example, calculate the statistical information based on data values and apply metadata to ensure that the data meets their needs. What type of requirements? For the startup program, it may be necessary to check whether the column that is about to execute the numerical calculation actually contains numbers!

The following list shows a simple function summary _ stats (), which obtains the result set and column index and generates summary statistics of column values. This function also lists the number of missing values, which are detected by checking NULL. These computations include the requirements that must be met by two data items. summary_stats () uses the result set metadata for verification:

■ The specified column must exist (that is, the column index must be within the range of the result set column value ).

■ This column must contain numeric values.

If these conditions are not met, summary_stats () only prints the error message and returns it. The code is as follows:

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.