mysql 常用的函数方法concat,substr,substring,substring_index,left,right
2017-06-22 10:39
676 查看
concat用法:
concat(str1,str2)返回字符串参数连接后的结果
eg:select concat(user_name,score) as newname from test1; ==>将user_name和score字段连接起来
substr用法:
mysql: substr(),substring()
oracle: substr()
sql server: substring()
substr(str,pos,len)//substr(str from pos for len) str从pos位置开始截取到len位置,注:pos第一个下标是1.
eg:select substr(t.user_name,1,3) as newname from test1 t; ==》取test1中的user_name字段,从第一个字符取到第三个字符,故取前三位字符
substring_index用法:
substring_index(str,delim,count):按某些字符的下标来截取字符串
eg:select substring_index(mobile,',',1) from test1 a; ==>mobile列按‘,’取,只取1个数量.故只显示第一个逗号前的数据
left用法:
left(str,len)从左边截取len长度字符串
eg:select left(t.mobile,4) from test1 t; ==>从mobile列中从左边取4个字符
right用法:
right(str,len)从右边截取len长度字符串
eg:select right(t.mobile,4) from test1 t; ==>从mobile列中从右边取4个字符
concat(str1,str2)返回字符串参数连接后的结果
eg:select concat(user_name,score) as newname from test1; ==>将user_name和score字段连接起来
substr用法:
mysql: substr(),substring()
oracle: substr()
sql server: substring()
substr(str,pos,len)//substr(str from pos for len) str从pos位置开始截取到len位置,注:pos第一个下标是1.
eg:select substr(t.user_name,1,3) as newname from test1 t; ==》取test1中的user_name字段,从第一个字符取到第三个字符,故取前三位字符
substring_index用法:
substring_index(str,delim,count):按某些字符的下标来截取字符串
eg:select substring_index(mobile,',',1) from test1 a; ==>mobile列按‘,’取,只取1个数量.故只显示第一个逗号前的数据
left用法:
left(str,len)从左边截取len长度字符串
eg:select left(t.mobile,4) from test1 t; ==>从mobile列中从左边取4个字符
right用法:
right(str,len)从右边截取len长度字符串
eg:select right(t.mobile,4) from test1 t; ==>从mobile列中从右边取4个字符
相关文章推荐
- left,right,substring,substring_index MySQL截取字符串函数方法
- javascript字符串string常用的几种方法(indexOf/lastIndexOf/search/charAt/match/slice/substr/replace/concat/split
- Mysql字符串截取总结:left()、right()、substring()、substring_index()
- 最常用的截取函数有left,right,substring
- mysql的 函数 group_concat , substring_index 的使用以及 分库分表操作
- mysql的函数 SUBSTRING_INDEX
- OracleDB,MySQL字符串操作函数INSTR,SUBSTRING_INDEX
- 几个常用的javaScript字符串处理函数--split() .ion() .substring()和index()
- CString类常用方法----Left(),Mid(),Right()
- CString类常用方法----Left(),Mid(),Right()
- CString类常用方法----Left(),Mid(),Right()
- 【mysql】mysql中常用的字符串函数,如:replace、cast、concat等函数
- CString类常用方法----Left(),Mid(),Right() .
- mysql的left,right,substr,instr截取字符串,截取小数点float
- MySQL 中取子串函数 SUBSTR(SUBSTRING)
- mysql的left,right,substr,instr截取字符串,截取小数点float
- mysql截取函数常用方法使用说明
- Mysql的GROUP_CONCAT()函数使用方法
- mysql的left,right,substr,instr截取字符串,截取小数点float
- CString类常用方法----Left(),Mid(),Right()……