mysql like 검색방법

· 13년 전 · 4795 · 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,405
13년 전 조회 875
13년 전 조회 1,072
13년 전 조회 816
13년 전 조회 966
13년 전 조회 1,306
13년 전 조회 1,161
13년 전 조회 1,254
13년 전 조회 3,837
13년 전 조회 2,305
13년 전 조회 4,567
13년 전 조회 3,248
13년 전 조회 4,427
13년 전 조회 2,246
13년 전 조회 1,438
13년 전 조회 1,117
13년 전 조회 2,238
13년 전 조회 5,166
13년 전 조회 1,446
13년 전 조회 4,287
13년 전 조회 5,809
13년 전 조회 1,463
13년 전 조회 2,716
13년 전 조회 1,827
13년 전 조회 788
13년 전 조회 2,498
13년 전 조회 2,247
13년 전 조회 942
13년 전 조회 890
13년 전 조회 3,378
13년 전 조회 1,790
13년 전 조회 815
13년 전 조회 665
13년 전 조회 8,310
13년 전 조회 4,806
13년 전 조회 7,994
13년 전 조회 959
13년 전 조회 1,596
13년 전 조회 1,998
13년 전 조회 1,403
13년 전 조회 2,900
13년 전 조회 1,120
13년 전 조회 1,319
13년 전 조회 816
13년 전 조회 1,335
13년 전 조회 1,534
13년 전 조회 1.3만
13년 전 조회 1,256
13년 전 조회 4,796
13년 전 조회 1,763
13년 전 조회 804
13년 전 조회 1,108
13년 전 조회 3,919
13년 전 조회 1,084
13년 전 조회 4,737
13년 전 조회 829
13년 전 조회 991
13년 전 조회 1,406
13년 전 조회 8,932
13년 전 조회 1,633
13년 전 조회 2,681
13년 전 조회 1,829
13년 전 조회 2,083
13년 전 조회 2,172
13년 전 조회 1,246
13년 전 조회 1,434
13년 전 조회 1.8만
13년 전 조회 2,491
13년 전 조회 4,520
13년 전 조회 1,845
13년 전 조회 2,263
13년 전 조회 2,323
13년 전 조회 1.6만
13년 전 조회 1,251
13년 전 조회 1,089
13년 전 조회 888
13년 전 조회 1,775
13년 전 조회 3,360
13년 전 조회 3,586
13년 전 조회 2,283
13년 전 조회 5,826
13년 전 조회 2,970
13년 전 조회 6,182
13년 전 조회 1,803
13년 전 조회 2.1만
13년 전 조회 1,076
13년 전 조회 1,570
13년 전 조회 1.7만
13년 전 조회 2,939
13년 전 조회 1,195
13년 전 조회 3,911
13년 전 조회 1,358
13년 전 조회 1,503
13년 전 조회 948
13년 전 조회 2,688
13년 전 조회 1,668
13년 전 조회 827
13년 전 조회 1,068
13년 전 조회 7,635
🐛 버그신고