MySQL内置函数详细介绍

来源:互联网 发布:sql常用查询语句 编辑:程序博客网 时间:2024/06/05 04:30
MySQL内置函数字符串函数:selectconcat("hello","word");        链接字串 ->hello worldlcase("MYSQL")    转换成小写ucase("mysql")    转换成大写length("leyangjun")          string长度ltrim("   userName")           去除前端空格rtrim("userName   ")           去除后端空格repeat("linux",count)       重复count次( select repeat('d',2);重复输出2次dd)replace(str,search_str,replace_str)  在str中使用replace_str替换search_strsubstring(str,position[length])      从str的position开始,取length个字符串->substring 和 substr一样select substr("leyangjun",1,5);      从第一个开始取5个字符串space(count)            生成count(数字)个空格数学函数bin(decimal_number)         十进制转二进制(select bin(120);)ceiling(number2)            向上取整(select ceiling(10.10);--->11)floor(number2)            向下取整(select ceiling(10.10);--->10)Max(列)              取最大值MIN(列)              取最小值sqrt(number2)               开平方rand()                      返回0-1内的随机值日期函数:curdate();       返回当前日期curtime();       返回当前时间now();           返回当前的日期和时间unix_timestamp(date)   返回date的unix时间戳from_unixtime()        返回unix时间戳日期值week(date)             返回日期date为一年中的第几周year(date)             返回日期中的年份datediff(expr,expr2)   返回起始时间expr和结束时间expr2间隔天数select datediff("2014-08-03","2014-08-04");

0 0