mysql like 검색방법

· 13년 전 · 4802 · 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년 전 조회 877
13년 전 조회 6,416
13년 전 조회 883
13년 전 조회 1,077
13년 전 조회 829
13년 전 조회 966
13년 전 조회 1,311
13년 전 조회 1,169
13년 전 조회 1,261
13년 전 조회 3,842
13년 전 조회 2,310
13년 전 조회 4,577
13년 전 조회 3,257
13년 전 조회 4,434
13년 전 조회 2,256
13년 전 조회 1,448
13년 전 조회 1,124
13년 전 조회 2,245
13년 전 조회 5,177
13년 전 조회 1,451
13년 전 조회 4,294
13년 전 조회 5,821
13년 전 조회 1,474
13년 전 조회 2,730
13년 전 조회 1,833
13년 전 조회 790
13년 전 조회 2,509
13년 전 조회 2,252
13년 전 조회 946
13년 전 조회 894
13년 전 조회 3,386
13년 전 조회 1,800
13년 전 조회 823
13년 전 조회 669
13년 전 조회 8,317
13년 전 조회 4,814
13년 전 조회 8,004
13년 전 조회 963
13년 전 조회 1,602
13년 전 조회 2,009
13년 전 조회 1,407
13년 전 조회 2,906
13년 전 조회 1,126
13년 전 조회 1,327
13년 전 조회 824
13년 전 조회 1,343
13년 전 조회 1,545
13년 전 조회 1.3만
13년 전 조회 1,268
13년 전 조회 4,803
13년 전 조회 1,776
13년 전 조회 816
13년 전 조회 1,112
13년 전 조회 3,921
13년 전 조회 1,090
13년 전 조회 4,743
13년 전 조회 834
13년 전 조회 994
13년 전 조회 1,413
13년 전 조회 8,943
13년 전 조회 1,646
13년 전 조회 2,689
13년 전 조회 1,838
13년 전 조회 2,087
13년 전 조회 2,181
13년 전 조회 1,253
13년 전 조회 1,441
13년 전 조회 1.8만
13년 전 조회 2,499
13년 전 조회 4,524
13년 전 조회 1,851
13년 전 조회 2,273
13년 전 조회 2,331
13년 전 조회 1.6만
13년 전 조회 1,257
13년 전 조회 1,097
13년 전 조회 900
13년 전 조회 1,783
13년 전 조회 3,371
13년 전 조회 3,594
13년 전 조회 2,294
13년 전 조회 5,833
13년 전 조회 2,979
13년 전 조회 6,193
13년 전 조회 1,806
13년 전 조회 2.1만
13년 전 조회 1,083
13년 전 조회 1,578
13년 전 조회 1.7만
13년 전 조회 2,946
13년 전 조회 1,200
13년 전 조회 3,918
13년 전 조회 1,367
13년 전 조회 1,508
13년 전 조회 958
13년 전 조회 2,695
13년 전 조회 1,679
13년 전 조회 832
13년 전 조회 1,076
13년 전 조회 7,646
🐛 버그신고