Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
| 29 | 30 | 31 |
Tags
- matplotlib
- string
- del
- elbow method
- nan
- pandas
- Python
- Machine Learning
- 분류 결과표
- dendrogram
- Dictionary
- append()
- function
- DataAccess
- 덴드로그램
- hierarchical_clustering
- IN
- data
- 최댓값
- analizer
- DataFrame
- count()
- wcss
- 반복문
- 최솟값
- len()
- list
- numpy
- sklearn
- insert()
Archives
- Today
- Total
개발공부
[MySQL] 문자열의 일부분만 가져오기 substr(), substring() 본문
문자열의 일부분 가져오기
substr(), substring()
두개는 같은 함수이다.
substring(컬럼이름, 시작위치(sql은 1부터시작), 끝위치)
or
substr(컬럼이름, 시작위치(sql은 1부터시작), 끝위치)
아래와 같은 books 테이블이 있다.

1. title을 처음부터 10글자 까지만 가져오기
select substring(title, 1, 10) as title
from books;

2. title의 맨 뒤에서 5번째 글자부터 끝가지 가져오기
select substring(title, -5) as title
from books;

3. title의 5번째 글자부터 12번째 글자까지 가져오기
select substr(title, 5, 12) as title
from books;

'Database > MySQL' 카테고리의 다른 글
| [MySQL] 데이터 중복 없이 선택 distinct, 데이터 정렬 order by (0) | 2022.05.16 |
|---|---|
| [MySQL] 문자열 교체 replace(), 거꾸로 변경 reverse(), 길이 구하기 char_length(), 대소문자 변경 upper(), lower() (0) | 2022.05.16 |
| [MYSQL] 컬럼 합치기 concat(), concat_ws() (0) | 2022.05.16 |
| 데이터 조작어 DML (INSERT, UPDATE, DELETE, SELECT) (0) | 2022.05.16 |
| MYSQL Workbench 스키마 생성하기, 테이블 생성하기 (0) | 2022.05.13 |