Home >Database >Mysql Tutorial >浅析MySQL之字符串函数_MySQL

浅析MySQL之字符串函数_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:25:44897browse

bitsCN.com

1. left函数, 对查询字段的字符串内容进行截取,用法select left(content,50) as summary from article; 在这里的意思是只查询content列内容的前50个字符,在这里汉字也只当作一个字符。

2. right函数,与left函数刚好相反,它对内容从后面进行截取。

3. upper函数,对查询的内容中的小写字母进行大写处理。select upper(title) as title from article;

4. lower函数,和upper刚好相反,它是进行小写处理。

5. substr函数,对字符串从指定位置,进行指定长度的裁剪,它比left和right更灵活。 select substr(content, 10, 50) from article, 从第10个字符(第一个字符为1不为0)开始截取50个字符;select substr(content,10)    from article,从第10个字符开始截取到末尾;select substr(content,

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn