Home > Database > Mysql Tutorial > body text

MySQL statistical minimum data Select Min

黄舟
Release: 2016-12-27 17:32:06
Original
2266 people have browsed it

Statistical minimum data

SELECT MIN() FROM syntax is used to count the minimum data of a field from the data table.

Syntax:

SELECT MIN(column) FROM tb_name
Copy after login

Please refer to MAX() for specific usage.

Explanation

The above statistical queries including ordinary field queries can be mixed:

SELECT MAX(uid) as max,MIN(uid)as min,AVG(uid) as avg FROM user
Copy after login

The query results are as follows:

MySQL statistical minimum data Select Min

But it should be noted that the results of statistical queries and ordinary field queries are often not what is expected. For example, if you want to query the user name with the largest uid (including uid):

//这种写法是错误的,尽管能执行
SELECT MAX(uid),username FROM user
//这种写法是正确的
SELECT uid,username FROM user ORDER BY uid DESC LIMIT 1
Copy after login

The above is the content of the MySQL statistical minimum data Select Min. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!