일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 티베로
- String Functions and Operators
- Oracle
- 방화벽
- Date and Time Function
- Tibero
- String Function and Operators
- 오라클
- 윈도우
- 전자정부표준프레임워크
- Data and Time Functions
- Sring Functions and Operators
- 전자정부 표준프레임워크
- SVN
- String Functions and Date Operators
- Date and Time Functions
- MySQL
- HTTP
- Today
- Total
웹이야기
[MySQL]SUBSTRING() 본문
MySQL 문자열 함수와 연산자
SUBSTRING()
- 문자열 자르기 정도 ?
SUBSTRING(str, pos)
SUBSTRING(str FROM pos)
SUBSTRING(str, pos, len)
SUBSTRING(str FROM pos FOR len)
의 형태
The forms without a len argument return substring from string str starting at position pos. The forms with a len argument return a substring len characters long from string str, starting at postion pos. The forms that use FROM are standard SQL syntax. It is also possible to use a negative value for pos. In this case, the beginning of the substring is pos characters from the end of the string, rather than the beginning. A negative value may be used for pos in any of the forms of this function. A value of 0 for pos returns an empty string
For all forms of SUBSTRING(), the position of the first character in the string from which the substring is to be extracted is reckoned as 1.
mysql> SELECT SUBSTRING('Quadratically', 5);
+-------------------------------+
| SUBSTRING('Quadratically', 5) |
+-------------------------------+
| ratically |
+-------------------------------+
1 row in set (0.00 sec)
mysql> SELECT SUBSTRING('foobarbar' FROM 4) ;
+-------------------------------+
| SUBSTRING('foobarbar' FROM 4) |
+-------------------------------+
| barbar |
+-------------------------------+
1 row in set (0.00 sec)
mysql> SELECT SUBSTRING('Quadratically', 5, 6) ;
+----------------------------------+
| SUBSTRING('Quadratically', 5, 6) |
+----------------------------------+
| ratica |
+----------------------------------+
1 row in set (0.00 sec)
mysql> SELECT SUBSTRING('Saklia', -3);
+-------------------------+
| SUBSTRING('Saklia', -3) |
+-------------------------+
| lia |
+-------------------------+
1 row in set (0.00 sec)
mysql> SELECT SUBSTRING('Saklia', 3);
+------------------------+
| SUBSTRING('Saklia', 3) |
+------------------------+
| klia |
+------------------------+
1 row in set (0.00 sec)
mysql> SELECT SUBSTRING('Saklia', -5, 3) ;
+----------------------------+
| SUBSTRING('Saklia', -5, 3) |
+----------------------------+
| akl |
+----------------------------+
1 row in set (0.00 sec)
mysql> SELECT SUBSTRING('Saklia' FROM -4 FOR 2) ;
+-----------------------------------+
| SUBSTRING('Saklia' FROM -4 FOR 2) |
+-----------------------------------+
| kl |
+-----------------------------------+
1 row in set (0.00 sec)
mysql>
This function is multibyte safe.
If len is less than 1, the result is the empty st ring
'D > ORACLE' 카테고리의 다른 글
[MySQL]TO_BASE64() (0) | 2020.06.11 |
---|---|
[MySQL] LOCATE() (0) | 2020.04.14 |
오라클 hr 계정 unlock , hr 계정 lock 풀기 (0) | 2020.03.22 |
오라클 연산자 (0) | 2020.03.22 |
오라클 집합 연산자 (0) | 2020.03.16 |