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
- function
- dendrogram
- DataAccess
- matplotlib
- wcss
- 최솟값
- nan
- numpy
- DataFrame
- count()
- Machine Learning
- elbow method
- 최댓값
- 덴드로그램
- string
- list
- 분류 결과표
- sklearn
- len()
- analizer
- data
- pandas
- IN
- hierarchical_clustering
- append()
- Python
- insert()
- Dictionary
- 반복문
- del
Archives
- Today
- Total
개발공부
[MySQL] 원하는 행 가져오기 limit, 문자열 검색 like 본문
books 테이블

1. 원하는 행 가져오기 limit
limit number - 처음부터 number만큼의 행 가져오기
limit number1, number2 - number1 부터 number2 개 만큼 가져오기
number1은 0부터 시작한다.
books 테이블의 데이터를 3개만 가져오기
select *
from books
limit 3;

최근 released_year 이 7번째로 작은것부터 3개의 데이터 가져오기
limit 의 offset은 0부터 시작이기 때문에 6으로 작성한다.
select *
from books
order by released_year desc
limit 6, 3;

문자열 검색 like
title에 'the' 가 들어있는 데이터만 가져오기
select *
from books
where title like '%the%';

'the'로 시작하는 데이터만 가져오기
select *
from books
where title like 'the%';

'the'로 끝나는 데이터만 가져오기
select *
from books
where title like '%the';

데이터중 원하는 숫자 형태로 이루어져 있는것 찾기 언더스코어( _ )
언더 스코어 갯수만큼, 숫자의 자리수를 나타낸다.
stock_quantity가 두자리 숫자로 이루어진것만 가져오기
select *
from books
where stock_quantity like '__';

title에 퍼센트 기호가 있는 책을 가져오기
이스케이프 문자 \와 같이 사용한다. \%
select *
from books
where title like '%\%%';
