MySQL函数
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MySQL函数,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1418字,纯文字阅读大概需要3分钟。
内容图文
![MySQL函数](/upload/InfoBanner/zyjiaocheng/459/476212486efa42d489447e90c24beb94.jpg)
字符函数
时间函数
数学函数
其它函数
delimiter // 改变结束符
call sp1() 调用sp1函数
select ifnull(salary, 0) from table1; 替换null值, 若salary的值为null则用0来替换
date_format
select date_format(now(),‘%Y年-%m月-%d日‘);
select date_format(now(),‘%Y年-%M月-%D日‘);
round (取小数位数,四舍五入)
mysql> select round(8.756,1);
| 8.8 |
mysql> select truncate(8.756,1);
| 8.7 |
truncate (取小数位数)
select truncate(3.433,1);
select truncate(3.433,0);
length 占的字节
mysql> select length(‘中国‘);
| length(‘中国‘) |
| 6 |
char_length 占的字符
select char_length(password(‘aixocm‘));
mysql> select char_length(‘中国‘);
| char_length(‘中国‘) |
| 2 |
left/right
select left(‘abcsefg‘,4);
ltrim 去掉左边空格
rtrim
trim
select trim(‘ abc ‘) as ‘ds‘;
repeat
select repeat(‘abc‘,3);
replace
select replace(‘hi tom‘, ‘tom‘, ‘mike‘);
abs 取绝对值
select abs(-32);
mod
select 10%3;
select mod(10,3);
rand 随机数
select rand()*10;
ceil 去掉小数位
select ceil(rand()*10);
round
md5 加密
select md5(‘aixocm‘);
inet_aton IP地址换成数值
select inet_aton(‘192.168.0.3‘);
select * from t2 where inet_aton(prodName) > inet_aton(‘192.168.0.1‘) and inet_aton(prodName) < inet_aton(‘192.168.0.5‘);
repeat(‘abc‘,3); 函数
show function status\G
MySQL函数
标签:
本文系统来源:http://www.cnblogs.com/wsl222000/p/4950399.html
内容总结
以上是互联网集市为您收集整理的MySQL函数全部内容,希望文章能够帮你解决MySQL函数所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。