mysql字符串函数
1、求字符串的长度LENGTH()
SELECT LENGTH('hellojava') FROM DUAL
2、字符串大小写转换UPPER(),LOWER()
SELECT LOWER('hellojava') ROM DUAL
SELECT UPPER('hellojava') FROM DUAL
3、截取字符串左侧的空格LTRIM(),截取字符串的右侧空格RTRIM()
SELECT LTRIM(' hellojava') FROM DUAL
SELECT RTRIM('hellojava ') FROM DUAL
4、截取字符串两侧的空格 TRIM()
SELECT TRIM(' hellojava ') FROM DUAL
5、取子字符串SUBSTRING(string,start_postion,length)
SELECT SUBSTRING('hellojava',2,3) FROM DUAL
6、计算子字符串的位置 INSTR(string,substring)
SELECT instr('hellojava','java' ) FROM dual
7、从左侧开始取子字符串 LEFT(string,length)
SELECT left('hello java',3) FROM dual
8、从右侧开始取字符串RIGHT(string,length)
SELECT RIGHT('hello java',3) FROM dual
9、字符串替换函数REPLACE(string,string_tobe_replace,string_to_replace)
SELECT replace('hello java','java','hello') FROM dual
10、得到字符的ASCII码 ASCII()
SELECT ASCII('hello') FROM dual
11、得到一个ASCII码数字对应的字符char()
SELECT char(104) FROM dual