龙空技术网

MySQL实战第72篇:常用的函数,在MySQL上运用实训

水果业务分析师 329

前言:

现时小伙伴们对“mysqlinstr函数”可能比较关切,大家都需要了解一些“mysqlinstr函数”的相关资讯。那么小编在网摘上搜集了一些关于“mysqlinstr函数””的相关知识,希望姐妹们能喜欢,看官们快快来了解一下吧!

欢迎来到MySQL实战第72篇,修炼500篇,让自己有一个目标!

1.求绝对值abs()

例:求-2,33,-3.4的绝对值

select abs(-2),abs(33),abs(-3.4);

2.求余数mod(x,y)

例:对mod(31,8),mod(52,88),mod(45.99.6)进行求余运算

select mod(31,8),mod(52,88),mod(45.99,6);

3.返回最小整数:

使用ceiling函数返回最小整数

select ceiling(45.34),ceiling(-45.34);

4.使用round(x)函数对操作数进行四舍五入操作

select round(45.34),round(45.56,1),round(-45.66,1),round(45.56,-1);

5.使用char_length函数计算字符串字符的个数

select char_length('football'),length('football');

6.使用concat函数、group_concat()连接字符串

select concat('my','SQL');

select s_id,group_concat(f_name) from fruits group by s_id;

7.使用left函数返回字符串中左边的字符

select left('myfootball',4);

8.使用right函数返回字符串中右边的字符

select right('myfootball',4);

9.使用MID()函数获取指定位置处的子字符串

select mid('football',4 ) f1,mid('football',-4) f2,mid('football',5,-3) f3,mid('football',-5,3) f4;

10.使用locate,position,instr函数查找字符串中制定字符串的开始位置。

select locate('ball','football'),position('ball' in'football'),instr('football','ball');

求关注,修炼MySQL,有500篇,让自己更加适应!

标签: #mysqlinstr函数 #mysql实训感悟