Home > Database > Mysql Tutorial > mysql字符串截取命令_MySQL

mysql字符串截取命令_MySQL

WBOY
Release: 2016-06-01 13:39:10
Original
969 people have browsed it

bitsCN.com


mysql字符串截取命令

 

1. substring_index

substring_index(str,delim,count)
 

[html]    

mysql> select substring_index('a-b-c-d','-',-1);  

+-----------------------------------+  

| substring_index('a-b-c-d','-',-1) |  

+-----------------------------------+  

| d                                 |   

+-----------------------------------+  

1 row in set (0.00 sec)  

  

mysql> select substring_index('a-b-c-d','-',1);  

+----------------------------------+  

| substring_index('a-b-c-d','-',1) |  

+----------------------------------+  

| a                                |   

+----------------------------------+  

1 row in set (0.00 sec)  

2. SUBSTRING

SUBSTRING(str,pos,len)

SUBSTRING(str FROM pos FOR len)

SUBSTRING(str,pos)

SUBSTRING(str FROM pos)
 

[html] 

mysql> select substring((substring_index('a-b-c-d','-',2)),2);  

+-------------------------------------------------+  

| substring((substring_index('a-b-c-d','-',2)),2) |  

+-------------------------------------------------+  

| -b                                              |   

+-------------------------------------------------+  

1 row in set (0.01 sec)  
 

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template