MySQL函数
-
常用函数
SELECT ABS(-8)
SELECT CEILING(9.4)
SELECT FLOOR(9.4)
SELECT RAND()
SELECT SIGN()
SELECT CHAR_LENGTH()
SELECT CONCAT('hello','world')
SELECT LOWER()
SELECT UPPER()
SELECT REPLACE('坚持就能成功','坚持','努力')
SELECT REVERSE('坚持就能成功')
SELECT CURRENT_DATE()
SELECT CURDATE()
SELECT NOW()
SELECT LOCALTIME()
SELECT SYSDATE()
SELECT YEAR(NOW())
SELECT MONTH(NOW())
SELECT DAY(NOW())
SELECT HOUR(NOW())
SELECT MINUTE(NOW())
SELECT SECOND(NOW())
SELECT SYSTEM_USER()
SELECT USER()
SELECT VERSION()
-
聚合函数
函数名称 | 描述 |
---|
COUNT() | 计数 |
SUM() | 求和 |
AVG() | 平均值 |
MAX() | 最大值 |
MIN() | 最小 |
… | … |
SELECT COUNT(id) FROM `student`
SELECT COUNT(*) FROM `student`
SELECT COUNT(1) FROM `student`
SELECT SUM(`age`) FROM `student`
SELECT AVG(`age`) FROM `student`
SELECT MAX(`age`) FROM `student`
SELECT MIN(`age`) FROM `student`