System/OS
2013.04.23 14:35
[sql] 조회구문(select)에서 중복 데이터를 한 번만 출력 (distinct)
조회 수 33908 댓글 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한 값으로 조건을 줘도 됨..
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
166 | System/OS | [linux] CentOS 6.x Cati 설치 (yum) | hooni | 2014.01.17 | 48590 |
165 | System/OS | [linux] CentOS Apache Httpd에 https 적용 | hooni | 2014.03.05 | 4476 |
164 | System/OS | [linux] CentOS 에 APM 설치하기 | hooni | 2015.01.02 | 1684 |
163 | System/OS | [linux] CentOS 터미널 언어 설정(한글/영어) | hooni | 2013.12.22 | 18509 |
162 | System/OS | [linux] DHCP(Dynamic Host Configuration Protocol) 서버 | hooni | 2003.04.23 | 13023 |
161 | System/OS | [linux] DNS(Domain Name System) 설치, 설정 | hooni | 2003.04.23 | 12438 |
160 | System/OS | [linux] GD 라이브러리 설치 방법.. | hooni | 2013.04.23 | 11367 |
159 | System/OS | [linux] iconv를 이용하여 euc-kr 문서를 utf-8로 대량으로 변환하기 | hooni | 2014.01.09 | 12215 |
158 | System/OS | [linux] ipchains 사용예(패킷 필터링) | hooni | 2003.04.23 | 14167 |
157 | System/OS | [linux] ipchains 옵션 | hooni | 2003.04.23 | 13607 |
156 | System/OS | [linux] ipfwadm를 이용한 패킷필터링(구버전) | hooni | 2003.04.23 | 13011 |
155 | System/OS | [linux] iptables 명령어 매뉴얼(options) | hooni | 2003.04.23 | 11329 |