mysql like 검색방법

· 13년 전 · 4911 · 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년 전 조회 972
13년 전 조회 6,495
13년 전 조회 983
13년 전 조회 1,179
13년 전 조회 912
13년 전 조회 1,054
13년 전 조회 1,409
13년 전 조회 1,269
13년 전 조회 1,346
13년 전 조회 3,922
13년 전 조회 2,401
13년 전 조회 4,672
13년 전 조회 3,349
13년 전 조회 4,526
13년 전 조회 2,341
13년 전 조회 1,554
13년 전 조회 1,216
13년 전 조회 2,337
13년 전 조회 5,274
13년 전 조회 1,549
13년 전 조회 4,398
13년 전 조회 5,916
13년 전 조회 1,577
13년 전 조회 2,832
13년 전 조회 1,927
13년 전 조회 894
13년 전 조회 2,605
13년 전 조회 2,344
13년 전 조회 1,037
13년 전 조회 993
13년 전 조회 3,470
13년 전 조회 1,899
13년 전 조회 922
13년 전 조회 785
13년 전 조회 8,417
13년 전 조회 4,903
13년 전 조회 8,111
13년 전 조회 1,057
13년 전 조회 1,702
13년 전 조회 2,107
13년 전 조회 1,504
13년 전 조회 3,013
13년 전 조회 1,242
13년 전 조회 1,417
13년 전 조회 920
13년 전 조회 1,459
13년 전 조회 1,638
13년 전 조회 1.3만
13년 전 조회 1,368
13년 전 조회 4,912
13년 전 조회 1,882
13년 전 조회 942
13년 전 조회 1,208
13년 전 조회 4,022
13년 전 조회 1,192
13년 전 조회 4,842
13년 전 조회 948
13년 전 조회 1,090
13년 전 조회 1,532
13년 전 조회 9,048
13년 전 조회 1,766
13년 전 조회 2,801
13년 전 조회 1,950
13년 전 조회 2,191
13년 전 조회 2,287
13년 전 조회 1,353
13년 전 조회 1,545
13년 전 조회 1.8만
13년 전 조회 2,609
13년 전 조회 4,633
13년 전 조회 1,964
13년 전 조회 2,388
13년 전 조회 2,455
13년 전 조회 1.6만
13년 전 조회 1,355
13년 전 조회 1,222
13년 전 조회 1,006
13년 전 조회 1,902
13년 전 조회 3,469
13년 전 조회 3,686
13년 전 조회 2,405
13년 전 조회 5,951
13년 전 조회 3,090
13년 전 조회 6,305
13년 전 조회 1,914
13년 전 조회 2.1만
13년 전 조회 1,195
13년 전 조회 1,692
13년 전 조회 1.7만
13년 전 조회 3,050
13년 전 조회 1,311
13년 전 조회 4,021
13년 전 조회 1,469
13년 전 조회 1,616
13년 전 조회 1,067
13년 전 조회 2,807
13년 전 조회 1,791
13년 전 조회 947
13년 전 조회 1,187
13년 전 조회 7,760