데이터베이스
[ MySQL ] 데이터 중복 제거 distinct
zzuvely
2022. 5. 16. 17:36
- distinct
: MySQL에서 중복된 데이터를 제거하기 위하여 사용한다.
- distinct 사용법
select distinct [ 컬럼명 ]
from [ 테이블명 ];
- distinct 예제
예제 1) author_lname 의 이름을 중복 없이 가져오세요.
select distinct author_lname
from books;
예제 2) 작가의 full_name을 중복없이 가져오세요.
select distinct concat(author_fname, ' ', author_lname) as full_name
from books;
예제 3) author_fname 의 갯수를 출력하세요
select count( distinct author_fname ) as count
from books;