常用函数
SELECT ABS(-8)
SELECT CEILING(9.1)
SELECT FLOOR(8.8)
SELECT RAND()
SELECT SIGN(-11)
SELECT CHAR_LENGTH('每天进步一点点')
SELECT CONCAT('df','wo','啊啊啊')
SELECT INSERT('我爱我家',2,1,'超级爱')
SELECT LOWER('aaaAAADDVVXccs')
SELECT UPPER('aaaAAADDVVXccs')
SELECT INSTR('lalalalcfsd','c')
SELECT REPLACE('wwwwscfxdfggvv','sc','bbb')
SELECT SUBSTR('abcdefghrgklmn',4,4)
SELECT REVERSE('aabbcc')
SELECT CURRENT_DATE()
SELECT CURDATE()
SELECT NOW()
SELECT LOCALTIME()
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 * FROM `score`
SELECT COUNT(`num`) FROM score
SELECT COUNT(*) FROM score
SELECT COUNT(1) FROM score
SELECT SUM(`num`) AS 总分 FROM `score`
SELECT AVG(`num`) AS 平均分 FROM `score`
SELECT MAX(`num`) AS 最高分 FROM `score`
SELECT MIN(`num`) AS 最低分 FROM `score`