MySQL 한글 자음(초성) 검색 RLIKE > 데이터베이스

본문 바로가기
사이트 내 전체검색


회원로그인

데이터베이스

MySQL | MySQL 한글 자음(초성) 검색 RLIKE

페이지 정보

작성자 100K5 작성일15-12-04 10:21 조회21,476회 댓글0건

본문

// 한글 자음의 초성으로 검색하기

if($find == 'ㄱ'){
 $where = "and (field_name RLIKE '^(ㄱ|ㄲ)' OR ( field_name >= '가' AND field_name < '나' )) order by field_name";
}else if($find == 'ㄴ'){
 $where = "and (field_name RLIKE '^ㄴ' OR ( field_name >= '나' AND field_name < '다' )) order by field_name";
}else if($find == 'ㄷ'){
 $where = "and (field_name RLIKE '^(ㄷ|ㄸ)' OR ( field_name >= '다' AND field_name < '라' )) order by field_name";
}else if($find == 'ㄹ'){
 $where = "and (field_name RLIKE '^ㄹ' OR ( field_name >= '라' AND field_name < '마' )) order by field_name";
}else if($find == 'ㅁ'){
 $where = "and (field_name RLIKE '^ㅁ' OR ( field_name >= '마' AND field_name < '바' )) order by field_name";
}else if($find == 'ㅂ'){
 $where = "and (field_name RLIKE '^ㅂ' OR ( field_name >= '바' AND field_name < '사' )) order by field_name";
}else if($find == 'ㅅ'){
 $where = "and (field_name RLIKE '^(ㅅ|ㅆ)' OR ( field_name >= '사' AND field_name < '아' )) order by field_name";
}else if($find == 'ㅇ'){
 $where = "and (field_name RLIKE '^ㅇ' OR ( field_name >= '아' AND field_name < '자' )) order by field_name";
}else if($find == 'ㅈ'){
 $where = "and (field_name RLIKE '^(ㅈ|ㅉ)' OR ( field_name >= '자' AND field_name < '차' )) order by field_name";
}else if($find == 'ㅊ'){
 $where = "and (field_name RLIKE '^ㅊ' OR ( field_name >= '차' AND field_name < '카' )) order by field_name";
}else if($find == 'ㅋ'){
 $where = "and (field_name RLIKE '^ㅋ' OR ( field_name >= '카' AND field_name < '타' )) order by field_name";
}else if($find == 'ㅌ'){
 $where = "and (field_name RLIKE '^ㅌ' OR ( field_name >= '타' AND field_name < '파' )) order by field_name";
}else if($find == 'ㅍ'){
 $where = "and (field_name RLIKE '^ㅍ' OR ( field_name >= '파' AND field_name < '하' )) order by field_name";
}else if($find == 'ㅎ'){
 $where = "and (field_name RLIKE '^ㅎ' OR ( field_name >= '하')) order by field_name";
}else{
 $where = "order by field_name";
}

$qry     = "select * from table_name where $where";
$result  = mysql_query($qry);

댓글목록

등록된 댓글이 없습니다.


사이트소개 개인정보취급방침 서비스이용약관 Copyright © kkujunhee.net All rights reserved.
상단으로

개인정보관리책임자 : 관리자

모바일 버전으로 보기