访问 http://www.qqread.com/mysql/z381295.html
注:mysql中处理字符串时,默认第一个字符下标为1,即参数position必须大于等于1 。
更多内容请看MySQL数据备份、MySQL、MySQL安全专题,或进入讨论组讨论。
2 字符串函数
CHARSET(str) //返回字串字符集 CONCAT (string2 [,… ]) //连接字串,注意不要沿用ORACLE习惯
mysql> select concat('a','b'); +-----------------+ | concat('a','b') | +-----------------+ | ab | +-----------------+ 1 row in set (0.03 sec) mysql> select 'a'||'b'; +----------+ | 'a'||'b' | +----------+ | 0 | +----------+ 1 row in set, 2 warnings (0.00 sec)
INSTR (string ,substring ) //返回substring首次在string中出现的位置,不存在返回0 LCASE (string2 ) //转换成小写 LEFT (string2 ,length ) //从string2中的左起取length个字符 LENGTH (string ) //string长度 LOAD_FILE (file_name ) //从文件读取内容 LOCATE (substring , string [,start_position ] ) //同INSTR,但可指定开始位置 LPAD (string2 ,length ,pad ) //重复用pad加在string开头,直到字串长度 为length LTRIM (string2 ) //去除前端空格 REPEAT (string2 ,count ) //重复count次 REPLACE (str ,search_str ,replace_str ) //在str中用replace_str替换search_str RPAD (string2 ,length ,pad) //在str后用pad补充,直到长度length RTRIM (string2 ) //去除后端空格 STRCMP (string1 ,string2 ) //逐字符比较两字串大小, SUBSTRING (str , position [,length ]) //从str的position开始,取length个字符
注:mysql中处理字符串时,默认第一个字符下标为1,即参数position必须大于等于1 。
mysql> select substring('abcd',0,2); +-----------------------+ | substring('abcd',0,2) | +-----------------------+ | | +-----------------------+ 1 row in set (0.06 sec) mysql> select substring('abcd',1,2); +-----------------------+ | substring('abcd',1,2) | +-----------------------+ | ab | +-----------------------+ 1 row in set (0.00 sec)
TRIM([[BOTH|LEADING|TRAILING] [padding] FROM]string2) //去除指定位置的指定字符 UCASE (string2 ) //转换成大写 RIGHT(string2,length) //取string2最后length个字符 SPACE(count) //生成count个空格
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
相关专题
- 专访MySQL CEO:MySQL与企业级应用 (0次浏览)
- 深入了解MySQL系统日常管理 (0次浏览)
- 如何保护MySQL重要数据 (0次浏览)
- 浅析MySQL数据库常用管理 (0次浏览)
- 缓存PHP页面代码 可减轻CPU和MYSQL负担 (0次浏览)
- 浅析Tomcat5配置Mysql JDBC数据库连接池 (0次浏览)
- MySQL数据库敏感数据安全保护六大措施 (0次浏览)
- apache+php+mysql+serv_u迷你傻瓜安装程序 (0次浏览)
- Oracle,SQL Server,MySQL的自增变量设置 (0次浏览)
- Win2003下APACHE+PHP5+MYSQL4+PHPMYADMIN的简 (0次浏览)



