System/OS
2013.04.23 14:35
[sql] 조회구문(select)에서 중복 데이터를 한 번만 출력 (distinct)
Views 34070 Comment 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한 값으로 조건을 줘도 됨..
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
106 | System/OS | [ms-sql] 프로시져 예제.. | hooni | 2013.04.23 | 13507 |
105 | System/OS | [linux] 프로그램 설치방법 (내공쌓기) | hooni | 2003.04.23 | 13495 |
104 | System/OS | [linux] 쉘 스크립트에 대한 설명과 예제.. | hooni | 2003.04.23 | 13473 |
103 | System/OS | [linux] Xwindow/Xmanager 사용 | hooni | 2003.04.23 | 13404 |
102 | System/OS | [linux] 계정관리하기(내공쌓기) | hooni | 2003.04.23 | 13320 |
101 | System/OS | [linux] 아파치설치/설정 - SSI(Server Side Include) | hooni | 2003.04.23 | 13261 |
100 | System/OS | [linux] 한글 URL 인식할 수 있게 아파치(Apache) 설정 (mod_url.c 설치) | hooni | 2013.04.23 | 13155 |
99 | System/OS | [linux] ipfwadm를 이용한 패킷필터링(구버전) | hooni | 2003.04.23 | 13103 |
98 | System/OS | [linux] DHCP(Dynamic Host Configuration Protocol) 서버 | hooni | 2003.04.23 | 13096 |
97 | System/OS | [linux] Proftpd 설치 가이드 | hooni | 2003.04.23 | 13084 |
96 | System/OS | [linux] 아파치 설치/설정(proxy) | hooni | 2003.04.23 | 13012 |
95 | System/OS | [router] 시스코 라우터 명령어 모드.. | hooni | 2013.04.23 | 13010 |