Mysql 常用函数

统计函数:

count()   统计记录条数,如 select count(*) from stu;

sum()     统计记录字段的和,如select sum(salary) from emp;

avg()     统计记录字段的平均值,如select avg(salary) from emp;   如果想取整,使用round函数:round(avg())

max()     查询字段中的最大值,如select max(age) from stu;

min()     查询字段中的最小值,如select min(age) from stu;

 

其他函数:

round 函数用于把数值字段舍入为指定的小数位数。(有小数的四舍五入)

FROM_UNIXTIME   将MYSQL中以INT(11)存储的时间以"YYYY-MM-DD"格式来显示。  语法:FROM_UNIXTIME(unix_timestamp,format)

        SELECT FROM_UNIXTIME(时间戳, '%Y-%m-%d %H:%i:%S')

posted @ 2015-07-27 15:25  王宇walkOn  阅读(133)  评论(0编辑  收藏  举报