字符串函数
select concat(‘hello‘,‘word‘,‘my‘) myname; // concat() 链接字符函数 输出 hellowordmy myname是别名
select lcase(‘MYSQL‘); //lcase() 转化成小写 输出 mysql
select length(‘string‘) //length() 输出字符串的长度
select ltrim(‘ strimg‘); //ltrim() 去除左边空格
select rtrim(‘string ‘); //rtrim() 去除右边空格
select repeat(‘php,‘,3); //repeat() 重复次数 输出 php,php,php,
select replace(‘linux is very good‘,‘linux‘,‘php‘) ; //replace()替换 输出 php is very good
select substr(‘linux is very good‘,1,5); //substr(),mysql 的起始位置是1,输出linux
select space(10); //space(); 生成10个空格
数学函数
select bin(192); //bin(); 十进制转二进制 ,输出 11000000
select celing(10.1); //celing(); 向上取整 输出 11
select floor(10.1); //floor(); 向下取整 输出 10
select max(col); // max() 取最大值 聚合使用
select min(col) //min() 取最小值 聚合使用
select sqrt(4); //sqrt() 开平方,输出2
select rand(); // rand() 随机 select * from tablename order by rand()
日期函数
select curdate(); //curdate(); 当前日期 年月日
select curtime(); //curtime(); 当前时间 时分秒
select now(); //now(); 现在的日期和时间 年月日时分秒
select unix_timestamp(); //unix_timestamp(); 返回当前unix时间戳
select week(‘2015-10-10‘); //week(); 返回当年的第几周
select year(‘2016-06-26‘); //year(); 输出 2016 ,返回当前的年份
select datediff(‘2016-10-10‘,‘2016-10-20‘); // 输出-10,返回两个日期相差几天
Mysql内置函数
标签:ted unix时间 rom curd 返回 max 空格 table 10个
本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉
本文系统来源:http://www.cnblogs.com/wt645631686/p/6868065.html