'mysql 초성정렬'에 해당되는 글 1건

  1. 2010/12/27 visualp mysql에서 한글 범위지정 정렬, 초성 정렬

[원문]  :  http://tagbox.tistory.com/48

select * from table where name >= '가' and name < '나'
select * from table where name >= '하'


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

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

2010/12/27 12:28 2010/12/27 12:28
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/343

댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/343