SELECT 절에 DISTINCT 키워드를 사용하면 가능합니다. DISTINCT는 SELECT 절에 지정된 모든 데이터 필드의 조합에 적용됩니다.
예시
다음과 같이 DISTINCT 키워드를 적용한 'Student' 테이블이 있습니다. -
mysql> Select * from student; +------+---------+---------+-----------+ | Id | Name | Address | Subject | +------+---------+---------+-----------+ | 1 | Gaurav | Delhi | Computers | | 2 | Aarav | Mumbai | History | | 15 | Harshit | Delhi | Commerce | | 17 | Raman | Shimla | Computers | | 20 | Gaurav | Jaipur | History | +------+---------+---------+-----------+ 5 rows in set (0.00 sec) mysql> Select DISTINCT Address from student; +---------+ | Address | +---------+ | Delhi | | Mumbai | | Shimla | | Jaipur | +---------+ 4 rows in set (0.00 sec) mysql> Select DISTINCT * from student; +------+---------+---------+-----------+ | Id | Name | Address | Subject | +------+---------+---------+-----------+ | 1 | Gaurav | Delhi | Computers | | 2 | Aarav | Mumbai | History | | 15 | Harshit | Delhi | Commerce | | 17 | Raman | Shimla | Computers | | 20 | Gaurav | Jaipur | History | +------+---------+---------+-----------+ 5 rows in set (0.00 sec) mysql> Select DISTINCT name from student; +---------+ | name | +---------+ | Gaurav | | Aarav | | Harshit | | Raman | +---------+ 4 rows in set (0.00 sec)