초성 검색 예제

db 2016. 4. 12. 15:52


        case 'ㄱ':
                $qry = "and (title RLIKE '^(ㄱ|ㄲ)' OR ( title >= '가' AND title < '나' )) order by title"; 
                break;
        case 'ㄴ':
                $qry = "and (title RLIKE '^ㄴ' OR ( title >= '나' AND title < '다' )) order by title"; 
                break;
        case 'ㄷ':
                $qry = "and (title RLIKE '^(ㄷ|ㄸ)' OR ( title >= '다' AND title < '라' )) order by title"; 
                break;
        case 'ㄹ':
                $qry = "and (title RLIKE '^ㄹ' OR ( title >= '라' AND title < '마' )) order by title"; 
                break;
        case 'ㅁ':
                $qry = "and (title RLIKE '^ㅁ' OR ( title >= '마' AND title < '바' )) order by title";        
                break;
        case 'ㅂ':
                $qry = "and (title RLIKE '^ㅂ' OR ( title >= '바' AND title < '사' )) order by title"; 
                break;
        case 'ㅅ':
                $qry = "and (title RLIKE '^(ㅅ|ㅆ)' OR ( title >= '사' AND title < '아' )) order by title"; 
                break;
        case 'ㅇ':
                $qry = "and (title RLIKE '^ㅇ' OR ( title >= '아' AND title < '자' )) order by title"; 
                break;
        case 'ㅈ':
                $qry = "and (title RLIKE '^(ㅈ|ㅉ)' OR ( title >= '자' AND title < '차' )) order by title"; 
                break;
        case 'ㅊ':
                $qry = "and (title RLIKE '^ㅊ' OR ( title >= '차' AND title < '카' )) order by title"; 
                break;
        case 'ㅋ':
                $qry = "and (title RLIKE '^ㅋ' OR ( title >= '카' AND title < '타' )) order by title"; 
                break;
        case 'ㅌ':
                $qry = "and (title RLIKE '^ㅌ' OR ( title >= '타' AND title < '파' )) order by title"; 
                break;
        case 'ㅍ':
                $qry = "and (title RLIKE '^ㅍ' OR ( title >= '파' AND title < '하' )) order by title"; 
                break;
        case 'ㅎ':
                $qry = "and (title RLIKE '^ㅎ' OR ( title >= '하')) order by title"; 
                break;
        default:
                $qry = "order by title";

'db' 카테고리의 다른 글

mysql 테이블 비우기  (0) 2016.11.03
mysql insert시 시간 자동 데이터 입력  (0) 2016.06.29
mysql 날짜 연산  (0) 2016.06.09
Posted by 몽키 D.루피
,