IT 강의
SQL 강의 핵심요약 #2. limit/distinct/count/distinct
척척박4
2021. 5. 5. 22:10
728x90
반응형
- limit : 테이블을 가져오는 시간이 짧아짐 (n까지만 불러오는 기능 / 내가 부르는 데이터가 내가 찾는 게 맞는지 확인이 필요할 때)
select * from orders where payment_method = "kakaopay" limit 5;
- distinct : select 사이에 원하는 데이터를 넣어주고 distinct (-)로 구분
: 보고자 하는 데이터가 몇 가지가 되는지 확인할 수 있음 (중복데이터 제외하고 가져오는 기능)
select distinct (payment_method) from orders;
- count : 몇 개인지 숫자 세보기
select count(*) from orders;
특정 칼럼을 보고 싶을 땐 아래와 같이
select name from users; select count(name) from users;
- distinct : 특정 ( ) 추출하기
select count(DISTINCT(name)) from users;
728x90
반응형