用在select 语句 ,能及子句 WHERE ORDERBY HAVING 中update delete 函数中能够将字段做为变量来调用,变量的值就是这个列对应的每一行记录 1、字符串函数 一、CONCAT 二、INSERT(STR,X,Y,INSERT) 将字符串X位置开始,Y个字符串长度替换为字符串INSERT; 三、lower() upper() 四、LEFT(STR,X) RIGHT(STR,Y) 返回Y/X个字符 NULL则不返回 五、LPAD(STR,N,PAD) RPAD(STR,N,PAD) 补全字符N个字符串 六、trim ltrin rtrim 去除空格 七、REPLACE(STR,A,B); 八、STRCMP(ST1,ST2) ASK码大小 九、SUBSTRING(STR,X,Y) 截取字符串 2、数值函数 一、ABS(X) 返回X的绝对值 二、ceil() 三、floor() 四、mod(x,y) 返回模 五、rand() 0- 1 六、round(x,y) 四舍五入 Y位小数 七、truncate(x,y)返回截断Y为小数 3、日期函数 curdate() 当前日期 curtime() 当前时间 now()当前日期时间 unix_timestamp(now()) 获取时间戳 from_unixtime(时间戳) week(now()) year(now()) hour(curtime()) minute(curtime()) monthname(now()) date_format(now(),"%Y-%m-%d %H:%i:%s") 4、流程控制函数 if(val,a,b) if null (val1,val2) case when [va] then [result1] else [default] end case when then 5、其余函数 select database() version() user() inet_aton('ip') inet_ntoa('inet_aton('ip')') password() md5()