웹이야기

[MySQL]SUBSTRING_INDEX() 본문

D/MySQL

[MySQL]SUBSTRING_INDEX()

yeon.Biju 2020. 6. 11. 15:47

MySQL 문자열 함수와 연산자

 

SUBSTRING_INDEX()

   -

 

SUBSTRING_INDEX(str, delim, count)

의 형태

 

Returns the substring from strikng str before count occurences of the delimiter delim. If count is positive, everything to the left of the final delimiter(counting from the left) is returned. If count is negative, everything to the right of the final delimter(counting from the right) is returned.

SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.

 

 

mysql> SELECT SUBSTRING_INDEX('www.mysql.com','.', 2);

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

| SUBSTRING_INDEX('www.mysql.com','.', 2) |

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

| www.mysql |

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

1 row in set (0.00 sec)

 

mysql> SELECT SUBSTRING_INDEX('www.mysql.com','.', -2);

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

| SUBSTRING_INDEX('www.mysql.com','.', -2) |

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

| mysql.com |

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

1 row in set (0.00 sec)

'D > MySQL' 카테고리의 다른 글

[MySQL]UCASE()  (0) 2020.06.18
[MySQL]TRIM()  (0) 2020.06.18
[MySQL]SUBSTR()  (0) 2020.06.11
[MySQL]SPACE()  (0) 2020.06.11
[MySQL] RTRIM()  (0) 2020.04.20
Comments