System/OS
2013.04.23 14:35
[sql] 조회구문(select)에서 중복 데이터를 한 번만 출력 (distinct)
조회 수 34066 댓글 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한 값으로 조건을 줘도 됨..
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
1113 | Develop | [Android Error] The number of method references in a .dex file cannot exceed 64K | hooni | 2016.11.10 | 895 |
1112 | Develop | [Android] 2010년에 만들었던 세미나 자료. | hooni | 2013.05.28 | 64743 |
1111 | Develop | [android] AlertDialog 메시지 창 띄우기 | hooni | 2015.07.09 | 984 |
1110 | Develop | [android] Android N requires the IDE to be running with Java 1.8 or later 오류 | hooni | 2016.08.30 | 952 |
1109 | Develop | [android] ArrayAdapter 테스트 파일 ㅎㅎ | hooni | 2013.04.23 | 45294 |
1108 | Develop | [android] ArrayAdapter를 이용하여 출력하기 | hooni | 2013.04.23 | 47393 |
1107 | Develop | [android] Calling activity function from separate class | hooni | 2016.11.15 | 1313 |
1106 | Develop | [android] Canvas를 이용해 이미지 확대/축소 하기 | hooni | 2013.04.23 | 60795 |
1105 | Develop | [android] dp, px 서로 변환 | hooni | 2016.10.21 | 3501 |
1104 | Develop | [android] GCM 사용하기 1 (GCM 서비스 신청하기) | hooni | 2013.07.06 | 51425 |
1103 | Develop | [android] How can I place app icon on launcher home screen? | hooni | 2016.11.15 | 1412 |
1102 | Develop | [android] keytool을 사용하여 키스토어 생성 | hooni | 2013.04.23 | 69577 |