合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
## 字符串函数 char_length():判断字符串的字符数. ~~~ select char_length('哈哈'); ~~~ 结果: ~~~ +-----------------------+ | char_length('哈哈') | +-----------------------+ | 2 | +-----------------------+ ~~~ * * * * * length() :判断字符串的字节数(与字符集); ~~~ select length('哈哈'); ~~~ 结果: ~~~ +------------------+ | length('哈哈') | +------------------+ | 6 | +------------------+ ~~~ * * * * * concat():连接字符串. ~~~ select concat('hello','world'); ~~~ 结果: ~~~ +-------------------------+ | concat('hello','world') | +-------------------------+ | helloworld | +-------------------------+ ~~~ * * * * * instr():判断字符在目标字符串中是否存在,存在返回其位置,不存在返回0. ~~~ select instr('helloworld','hello'); ~~~ 结果: ~~~ +-----------------------------+ | instr('helloworld','hello') | +-----------------------------+ | 1 | +-----------------------------+ ~~~ * * * * * lcase():全部小写. ~~~ select lcase('HELLO'); ~~~ 结果: ~~~ +----------------+ | lcase('HELLO') | +----------------+ | hello | +----------------+ ~~~ * * * * * left():从左侧开始截取,直到指定位置(位置如果超过长度,截取所有). ~~~ select left('hellowworld',5); ~~~ 结果: ~~~ +-----------------------+ | left('hellowworld',5) | +-----------------------+ | hello | +-----------------------+ ~~~ * * * * * ltrim():消除左边对应的空格. ~~~ select ltrim(' hello'); ~~~ 结果: ~~~ +-------------------+ | ltrim(' hello') | +-------------------+ | hello | +-------------------+ ~~~ * * * * * mid():从中间指定位置开始截取,如果不指定截取长度,直接到最后. ~~~ select mid('helloworld',5); ~~~ 结果: ~~~ +---------------------+ | mid('helloworld',5) | +---------------------+ | oworld | +---------------------+ ~~~