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
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
The query results are as follows:
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
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)!