mysql like 검색방법

· 13년 전 · 4789 · 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년 전 조회 872
13년 전 조회 6,402
13년 전 조회 869
13년 전 조회 1,067
13년 전 조회 813
13년 전 조회 961
13년 전 조회 1,301
13년 전 조회 1,159
13년 전 조회 1,253
13년 전 조회 3,834
13년 전 조회 2,302
13년 전 조회 4,562
13년 전 조회 3,243
13년 전 조회 4,421
13년 전 조회 2,243
13년 전 조회 1,437
13년 전 조회 1,112
13년 전 조회 2,234
13년 전 조회 5,164
13년 전 조회 1,445
13년 전 조회 4,282
13년 전 조회 5,806
13년 전 조회 1,452
13년 전 조회 2,713
13년 전 조회 1,822
13년 전 조회 785
13년 전 조회 2,495
13년 전 조회 2,243
13년 전 조회 941
13년 전 조회 885
13년 전 조회 3,377
13년 전 조회 1,783
13년 전 조회 809
13년 전 조회 661
13년 전 조회 8,309
13년 전 조회 4,801
13년 전 조회 7,990
13년 전 조회 954
13년 전 조회 1,595
13년 전 조회 1,994
13년 전 조회 1,397
13년 전 조회 2,896
13년 전 조회 1,117
13년 전 조회 1,315
13년 전 조회 812
13년 전 조회 1,332
13년 전 조회 1,530
13년 전 조회 1.3만
13년 전 조회 1,255
13년 전 조회 4,790
13년 전 조회 1,759
13년 전 조회 800
13년 전 조회 1,102
13년 전 조회 3,913
13년 전 조회 1,083
13년 전 조회 4,736
13년 전 조회 826
13년 전 조회 987
13년 전 조회 1,398
13년 전 조회 8,929
13년 전 조회 1,629
13년 전 조회 2,677
13년 전 조회 1,827
13년 전 조회 2,080
13년 전 조회 2,164
13년 전 조회 1,244
13년 전 조회 1,431
13년 전 조회 1.8만
13년 전 조회 2,484
13년 전 조회 4,518
13년 전 조회 1,841
13년 전 조회 2,261
13년 전 조회 2,322
13년 전 조회 1.6만
13년 전 조회 1,248
13년 전 조회 1,086
13년 전 조회 883
13년 전 조회 1,772
13년 전 조회 3,353
13년 전 조회 3,581
13년 전 조회 2,275
13년 전 조회 5,823
13년 전 조회 2,968
13년 전 조회 6,178
13년 전 조회 1,798
13년 전 조회 2.1만
13년 전 조회 1,072
13년 전 조회 1,565
13년 전 조회 1.7만
13년 전 조회 2,935
13년 전 조회 1,189
13년 전 조회 3,907
13년 전 조회 1,358
13년 전 조회 1,502
13년 전 조회 943
13년 전 조회 2,684
13년 전 조회 1,664
13년 전 조회 823
13년 전 조회 1,065
13년 전 조회 7,632
🐛 버그신고