쿼리문에 강제로 정렬(order by) 지정하는 방법
게시판/최근게시물 등에서 종종 특정글/특정 목록에 대해 정렬규칙을 버리고 싶을 때가 생긴다.. 그럴경우 아주 유용할것 같다. 이햐...셀렉트문 안에다가 스위치문을 쓸수가 있다..;; 보기 쉽게..보면.. select * from test order by case fld when 'A' then '1' when 'B' then '3' when 'C' then '2' else '9' end , no desc; 실제 적용 할때는 괄호로 묶어주면... select * from test order by (case fld when 'A' then '1' when 'B' then '3' when 'C' then '2' else '9' end), no desc; 출처 : phpschool
PHP
2008. 3. 6. 15:45