![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
MySQL常用函数
MySQL常用函数使用
weixin_38929027
这个作者很懒,什么都没留下…
展开
-
MySQL常用函数substring和substring_index
substring(str, pos): str->被截取的字符串, pos: 从第几位开始截取[整数,包含该位上的值]substring(str, pos, len): str->被截取的字符串, pos: 从第几位开始截取, len: 需要截取的长度[整数]pos可以为负数, 表示是从后倒数位数, 直到字符串结束或截够指定的长度substring_index(str, keyword, count): 按关键字截取str: 被截取字段, keyword: 关键字, count: 关原创 2020-06-11 14:35:09 · 1181 阅读 · 0 评论 -
MySQL常用函数concat和concat_ws
concat(str1, str2,…) 返回结果为连接参数产生的字符串,如果有任何一个参数为null,则返回值为null。select concat (id,‘,’ ,name) as info from t1;concat_ws()和concat()一样,将多个字符串连接成一个字符串,但是可以一次性指定分隔符语法: concat_ws(separator, str1, str2, …)select concat_ws(’,’,id ,name,age,phone) as info from t1原创 2020-06-11 14:22:51 · 98 阅读 · 0 评论 -
MySQL常用函数group_concat
完整的语法如下:group_concat([DISTINCT] 要连接的字段 [Order BY ASC/DESC 排序字段] [Separator ‘分隔符’])以id分组,把name字段的值打印在一行,逗号分隔(默认)mysql> select id,group_concat(name) from aa group by id;±-----±-------------------+| id| group_concat(name) |±-----±-------------------+原创 2020-06-11 14:16:42 · 91 阅读 · 0 评论 -
MySQL函数FIND_IN_SET
FIND_IN_SET(str,strlist)str 要查询的字符串strlist 字段名 参数以”,”分隔 如 (1,2,6,8)查询字段(strlist)中包含(str)的结果,返回结果为null或记录假如字符串str在由N个子链组成的字符串列表strlist 中,则返回值的范围在 1 到 N 之间。 一个字符串列表就是一个由一些被 ‘,’ 符号分开的子链组成的字符串。如果第一个参数是一个常数字符串,而第二个是type SET列,则FIND_IN_SET() 函数被优化,使用比特计算。 如果s原创 2020-06-11 14:06:08 · 83 阅读 · 0 评论