select 할때 특정 필드값 우선 순위 정하기
리눅스/MySQL2015. 1. 16. 11:42
반응형
mysql> select * from sysdocu where user='sawon'
order by CASE user
when 'superman' then 1
when 'superwoman' then 2
when 'superbaby' then 3
else 4
END;
[설명]
sysdocu 테이블에서 user 필드가 sawon 인것만 검색합니다.
순서는 superman 값이 1순위,
superwoman 값이 2순위,
superbaby 값이 3순위로 출력하고
나머지는 모두 4순위로 아래 출력 되게 합니다.
반응형
'리눅스 > MySQL' 카테고리의 다른 글
데이타를 임의 순서로 검색하되 특정 값만 가져오는 쿼리 (0) | 2015.01.16 |
---|---|
MySQL 중복 데이터 제거 (NOT IN) (0) | 2015.01.16 |
Warning: Using a password on the command line interface can be insecure. 메세지 안보이게 하기 (0) | 2015.01.16 |
./mysql_install_db: line 37: use: command not found (0) | 2015.01.16 |
Curses library not found. Please install appropriate package (0) | 2015.01.16 |
댓글()