System/OS
2013.04.23 14:35
[sql] 조회구문(select)에서 중복 데이터를 한 번만 출력 (distinct)
Views 34030 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 |
---|---|---|---|---|---|
202 | System/OS |
[apache2] Redirect HTTP to HTTPS
![]() |
hooni | 2022.02.03 | 825 |
201 | System/OS |
[macos] How to Fix ‘You Shut Down Your Computer Because of a Problem’
![]() |
hooni | 2022.06.01 | 921 |
200 | System/OS | 개인적으로 쓰고 있는 bash_profile | hooni | 2015.01.16 | 964 |
199 | System/OS | [linux] The Ultimate Wget Download Guide With 15 Awesome Examples | hooni | 2020.05.26 | 969 |
198 | System/OS | 개인적으로 쓰고 있는 zshrc 파일 | hooni | 2022.02.25 | 985 |
197 | System/OS | [mac] How to uninstall MySQL on Mac OS. | hooni | 2017.11.08 | 1020 |
196 | System/OS |
[virtualbox] VirtualBox에 Ubuntu 설치하기
![]() |
hooni | 2019.11.22 | 1046 |
195 | System/OS |
[펌] 마이크로서비스, 모노리포, SRE, ... 덮어놓고 구글 따라하면 안 되는 기술들
![]() |
hooni | 2020.10.15 | 1085 |
194 | System/OS | 콘솔에서 패스워드 걸린 zip 압축하는 명령 | hooni | 2018.03.02 | 1093 |
193 | System/OS | [mac] 패키지 매니저, MacPort | hooni | 2015.01.03 | 1109 |
192 | System/OS | [svn] Can't convert string from native encoding to 'UTF-8' 메시지가 나오는 경우 | hooni | 2014.12.18 | 1139 |
191 | System/OS | [mac] Homebrew/rvm/cocoapod setting | hooni | 2017.07.29 | 1155 |