System/OS
2013.04.23 14:35
[sql] 조회구문(select)에서 중복 데이터를 한 번만 출력 (distinct)
조회 수 35652 댓글 1
기본적인 쿼리
select distinct * from 테이블명;
distinct * 이란건 한 행의 전체 칼럼값이 중복되는 데이터를 제거하고 뽑아냄..
예를 들어 중복된걸 제거한 제목을 뽑아 낼려면..
select distinct 제목 from 테이블명;;
전체 칼럼을 뽑아 내는데 중복된게 제목이 중복된건 하나만 출력하고 싶다면 index값이 있어야 함.
select * from 테이블명 where index in (select max(index) from 테이블명 group by 제목)
그리고 정렬은..
select * from 테이블명 where index in (select max(index) from 테이블명 group by 제목) order by 제목
만약 index값이 없다면 unique한 값으로 조건을 줘도 됨..
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
132 | System/OS |
[mac] Mac OS 패키지 매니저, HomeBrew
![]() |
hooni | 2015.01.03 | 2559 |
131 | System/OS | [mac] How to uninstall MySQL on Mac OS. | hooni | 2017.11.08 | 2648 |
130 | System/OS | [mac] Homebrew/rvm/cocoapod setting | hooni | 2017.07.29 | 2668 |
129 | System/OS | [mac] Charlesproxy 간단한 설정 내용~ | hooni | 2013.11.12 | 13267 |
128 | System/OS |
[macos] How to Fix ‘You Shut Down Your Computer Because of a Problem’
![]() |
hooni | 2022.06.01 | 4528 |
127 | System/OS | [linux] 한글 URL 인식할 수 있게 아파치(Apache) 설정 (mod_url.c 설치) | hooni | 2013.04.23 | 13967 |
126 | System/OS | [linux] 프로세스의 stat 상태에 대한 설명 | hooni | 2013.04.23 | 11889 |
125 | System/OS | [linux] 프로세스 상태확인(ps) | hooni | 2003.04.23 | 13549 |
124 | System/OS | [linux] 프로그램 설치방법 (내공쌓기) | hooni | 2003.04.23 | 14241 |
123 | System/OS | [linux] 패킷의 소스 주소 바꾸기 | hooni | 2003.04.23 | 19540 |
122 | System/OS | [linux] 패킷 스니퍼링 | hooni | 2003.04.23 | 17210 |
121 | System/OS | [linux] 파일내 문자열 찾아 바꾸기 | hooni | 2013.04.23 | 13299 |