mysql like 검색방법

· 13년 전 · 4889 · 9
너무 궁금해서 아무리 찾아도 저와 비슷한 질문을 한 사람이 없더군요. like 검색시에 대소문자를 구분해서 검색하는 방법이 뭐가 있을까 생각하다가... 예를들어, name 컬럼에 abc 라는 값이 들어있고, select * from table where name like '%Bc%' 이렇게 해도 검색이 되더라 이겁니다. 물론 필드형을 바꾸어 주거나 하는 방법이 있지만.... select * from table where binary(name) like '%Bc%' 이렇게 하면 대소문자를 구분하여 검색이 안되고, select * from table where binary(name) like '%bc%' 이렇게 해야만 검색

첨부파일

mysql_like_검색.txt (50 bytes) 48회 2012-12-02 13:10
|

댓글 9개

http://dev.mysql.com/doc/refman/5.5/en/case-sensitivity.html

To make this search case sensitive, make sure that one of the operands has a case sensitive or binary collation. For example, if you are comparing a column and a string that both have the latin1 character set, you can use the COLLATE operator to cause either operand to have the latin1_general_cs or latin1_bin collation:

col_name COLLATE latin1_general_cs LIKE 'a%'
col_name LIKE 'a%' COLLATE latin1_general_cs
col_name COLLATE latin1_bin LIKE 'a%'
col_name LIKE 'a%' COLLATE latin1_bin
감사합니다
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
13년 전 조회 950
13년 전 조회 6,469
13년 전 조회 956
13년 전 조회 1,156
13년 전 조회 887
13년 전 조회 1,035
13년 전 조회 1,379
13년 전 조회 1,250
13년 전 조회 1,325
13년 전 조회 3,903
13년 전 조회 2,379
13년 전 조회 4,649
13년 전 조회 3,326
13년 전 조회 4,506
13년 전 조회 2,322
13년 전 조회 1,528
13년 전 조회 1,198
13년 전 조회 2,317
13년 전 조회 5,252
13년 전 조회 1,525
13년 전 조회 4,368
13년 전 조회 5,891
13년 전 조회 1,550
13년 전 조회 2,803
13년 전 조회 1,899
13년 전 조회 869
13년 전 조회 2,585
13년 전 조회 2,324
13년 전 조회 1,010
13년 전 조회 965
13년 전 조회 3,454
13년 전 조회 1,879
13년 전 조회 887
13년 전 조회 755
13년 전 조회 8,395
13년 전 조회 4,885
13년 전 조회 8,087
13년 전 조회 1,032
13년 전 조회 1,675
13년 전 조회 2,086
13년 전 조회 1,483
13년 전 조회 2,992
13년 전 조회 1,208
13년 전 조회 1,394
13년 전 조회 888
13년 전 조회 1,430
13년 전 조회 1,605
13년 전 조회 1.3만
13년 전 조회 1,344
13년 전 조회 4,890
13년 전 조회 1,859
13년 전 조회 899
13년 전 조회 1,185
13년 전 조회 3,996
13년 전 조회 1,165
13년 전 조회 4,819
13년 전 조회 919
13년 전 조회 1,070
13년 전 조회 1,498
13년 전 조회 9,028
13년 전 조회 1,741
13년 전 조회 2,774
13년 전 조회 1,916
13년 전 조회 2,168
13년 전 조회 2,262
13년 전 조회 1,329
13년 전 조회 1,521
13년 전 조회 1.8만
13년 전 조회 2,588
13년 전 조회 4,607
13년 전 조회 1,940
13년 전 조회 2,361
13년 전 조회 2,428
13년 전 조회 1.6만
13년 전 조회 1,327
13년 전 조회 1,193
13년 전 조회 981
13년 전 조회 1,878
13년 전 조회 3,449
13년 전 조회 3,664
13년 전 조회 2,383
13년 전 조회 5,930
13년 전 조회 3,063
13년 전 조회 6,282
13년 전 조회 1,895
13년 전 조회 2.1만
13년 전 조회 1,170
13년 전 조회 1,665
13년 전 조회 1.7만
13년 전 조회 3,029
13년 전 조회 1,289
13년 전 조회 4,003
13년 전 조회 1,448
13년 전 조회 1,591
13년 전 조회 1,046
13년 전 조회 2,783
13년 전 조회 1,760
13년 전 조회 923
13년 전 조회 1,163
13년 전 조회 7,732