mysql like 검색방법

· 13년 전 · 4809 · 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년 전 조회 881
13년 전 조회 6,417
13년 전 조회 888
13년 전 조회 1,082
13년 전 조회 831
13년 전 조회 969
13년 전 조회 1,317
13년 전 조회 1,176
13년 전 조회 1,263
13년 전 조회 3,844
13년 전 조회 2,317
13년 전 조회 4,580
13년 전 조회 3,263
13년 전 조회 4,437
13년 전 조회 2,260
13년 전 조회 1,456
13년 전 조회 1,127
13년 전 조회 2,248
13년 전 조회 5,183
13년 전 조회 1,454
13년 전 조회 4,298
13년 전 조회 5,828
13년 전 조회 1,478
13년 전 조회 2,731
13년 전 조회 1,833
13년 전 조회 792
13년 전 조회 2,515
13년 전 조회 2,255
13년 전 조회 948
13년 전 조회 902
13년 전 조회 3,388
13년 전 조회 1,803
13년 전 조회 825
13년 전 조회 673
13년 전 조회 8,322
13년 전 조회 4,818
13년 전 조회 8,013
13년 전 조회 966
13년 전 조회 1,607
13년 전 조회 2,015
13년 전 조회 1,412
13년 전 조회 2,912
13년 전 조회 1,133
13년 전 조회 1,329
13년 전 조회 828
13년 전 조회 1,348
13년 전 조회 1,546
13년 전 조회 1.3만
13년 전 조회 1,273
13년 전 조회 4,810
13년 전 조회 1,782
13년 전 조회 820
13년 전 조회 1,117
13년 전 조회 3,928
13년 전 조회 1,094
13년 전 조회 4,745
13년 전 조회 839
13년 전 조회 999
13년 전 조회 1,417
13년 전 조회 8,947
13년 전 조회 1,650
13년 전 조회 2,694
13년 전 조회 1,842
13년 전 조회 2,089
13년 전 조회 2,186
13년 전 조회 1,258
13년 전 조회 1,449
13년 전 조회 1.8만
13년 전 조회 2,504
13년 전 조회 4,527
13년 전 조회 1,856
13년 전 조회 2,277
13년 전 조회 2,334
13년 전 조회 1.6만
13년 전 조회 1,263
13년 전 조회 1,103
13년 전 조회 906
13년 전 조회 1,789
13년 전 조회 3,378
13년 전 조회 3,599
13년 전 조회 2,297
13년 전 조회 5,838
13년 전 조회 2,985
13년 전 조회 6,197
13년 전 조회 1,808
13년 전 조회 2.1만
13년 전 조회 1,089
13년 전 조회 1,585
13년 전 조회 1.7만
13년 전 조회 2,950
13년 전 조회 1,203
13년 전 조회 3,924
13년 전 조회 1,371
13년 전 조회 1,511
13년 전 조회 960
13년 전 조회 2,700
13년 전 조회 1,685
13년 전 조회 838
13년 전 조회 1,083
13년 전 조회 7,652
🐛 버그신고