mysql like 검색방법

· 13년 전 · 4769 · 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년 전 조회 848
13년 전 조회 6,390
13년 전 조회 852
13년 전 조회 1,043
13년 전 조회 786
13년 전 조회 946
13년 전 조회 1,283
13년 전 조회 1,135
13년 전 조회 1,242
13년 전 조회 3,815
13년 전 조회 2,287
13년 전 조회 4,545
13년 전 조회 3,230
13년 전 조회 4,403
13년 전 조회 2,226
13년 전 조회 1,423
13년 전 조회 1,092
13년 전 조회 2,207
13년 전 조회 5,150
13년 전 조회 1,425
13년 전 조회 4,267
13년 전 조회 5,783
13년 전 조회 1,424
13년 전 조회 2,690
13년 전 조회 1,803
13년 전 조회 768
13년 전 조회 2,474
13년 전 조회 2,222
13년 전 조회 919
13년 전 조회 863
13년 전 조회 3,356
13년 전 조회 1,765
13년 전 조회 795
13년 전 조회 637
13년 전 조회 8,283
13년 전 조회 4,779
13년 전 조회 7,973
13년 전 조회 929
13년 전 조회 1,566
13년 전 조회 1,977
13년 전 조회 1,379
13년 전 조회 2,876
13년 전 조회 1,094
13년 전 조회 1,300
13년 전 조회 792
13년 전 조회 1,312
13년 전 조회 1,511
13년 전 조회 1.3만
13년 전 조회 1,229
13년 전 조회 4,770
13년 전 조회 1,741
13년 전 조회 782
13년 전 조회 1,081
13년 전 조회 3,894
13년 전 조회 1,066
13년 전 조회 4,716
13년 전 조회 811
13년 전 조회 969
13년 전 조회 1,373
13년 전 조회 8,905
13년 전 조회 1,610
13년 전 조회 2,660
13년 전 조회 1,808
13년 전 조회 2,051
13년 전 조회 2,144
13년 전 조회 1,220
13년 전 조회 1,416
13년 전 조회 1.8만
13년 전 조회 2,464
13년 전 조회 4,502
13년 전 조회 1,829
13년 전 조회 2,241
13년 전 조회 2,304
13년 전 조회 1.6만
13년 전 조회 1,220
13년 전 조회 1,072
13년 전 조회 861
13년 전 조회 1,746
13년 전 조회 3,338
13년 전 조회 3,564
13년 전 조회 2,257
13년 전 조회 5,805
13년 전 조회 2,953
13년 전 조회 6,156
13년 전 조회 1,771
13년 전 조회 2.1만
13년 전 조회 1,052
13년 전 조회 1,541
13년 전 조회 1.7만
13년 전 조회 2,917
13년 전 조회 1,170
13년 전 조회 3,884
13년 전 조회 1,335
13년 전 조회 1,478
13년 전 조회 924
13년 전 조회 2,658
13년 전 조회 1,651
13년 전 조회 800
13년 전 조회 1,046
13년 전 조회 7,606
🐛 버그신고