mysql like 검색방법

· 13년 전 · 4829 · 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년 전 조회 905
13년 전 조회 6,431
13년 전 조회 905
13년 전 조회 1,097
13년 전 조회 843
13년 전 조회 987
13년 전 조회 1,332
13년 전 조회 1,191
13년 전 조회 1,276
13년 전 조회 3,859
13년 전 조회 2,330
13년 전 조회 4,591
13년 전 조회 3,275
13년 전 조회 4,457
13년 전 조회 2,277
13년 전 조회 1,474
13년 전 조회 1,147
13년 전 조회 2,266
13년 전 조회 5,204
13년 전 조회 1,468
13년 전 조회 4,315
13년 전 조회 5,844
13년 전 조회 1,495
13년 전 조회 2,750
13년 전 조회 1,852
13년 전 조회 809
13년 전 조회 2,534
13년 전 조회 2,269
13년 전 조회 968
13년 전 조회 924
13년 전 조회 3,408
13년 전 조회 1,828
13년 전 조회 843
13년 전 조회 690
13년 전 조회 8,343
13년 전 조회 4,836
13년 전 조회 8,033
13년 전 조회 978
13년 전 조회 1,617
13년 전 조회 2,030
13년 전 조회 1,429
13년 전 조회 2,928
13년 전 조회 1,148
13년 전 조회 1,344
13년 전 조회 843
13년 전 조회 1,372
13년 전 조회 1,570
13년 전 조회 1.3만
13년 전 조회 1,297
13년 전 조회 4,830
13년 전 조회 1,798
13년 전 조회 838
13년 전 조회 1,133
13년 전 조회 3,943
13년 전 조회 1,113
13년 전 조회 4,769
13년 전 조회 860
13년 전 조회 1,014
13년 전 조회 1,434
13년 전 조회 8,961
13년 전 조회 1,670
13년 전 조회 2,705
13년 전 조회 1,854
13년 전 조회 2,105
13년 전 조회 2,206
13년 전 조회 1,277
13년 전 조회 1,472
13년 전 조회 1.8만
13년 전 조회 2,523
13년 전 조회 4,542
13년 전 조회 1,881
13년 전 조회 2,297
13년 전 조회 2,356
13년 전 조회 1.6만
13년 전 조회 1,275
13년 전 조회 1,120
13년 전 조회 923
13년 전 조회 1,812
13년 전 조회 3,392
13년 전 조회 3,617
13년 전 조회 2,321
13년 전 조회 5,860
13년 전 조회 2,999
13년 전 조회 6,222
13년 전 조회 1,838
13년 전 조회 2.1만
13년 전 조회 1,112
13년 전 조회 1,605
13년 전 조회 1.7만
13년 전 조회 2,972
13년 전 조회 1,221
13년 전 조회 3,936
13년 전 조회 1,392
13년 전 조회 1,536
13년 전 조회 984
13년 전 조회 2,721
13년 전 조회 1,699
13년 전 조회 853
13년 전 조회 1,096
13년 전 조회 7,668