mysql like 검색방법

· 13년 전 · 4754 · 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년 전 조회 839
13년 전 조회 6,386
13년 전 조회 847
13년 전 조회 1,030
13년 전 조회 771
13년 전 조회 935
13년 전 조회 1,272
13년 전 조회 1,125
13년 전 조회 1,234
13년 전 조회 3,802
13년 전 조회 2,279
13년 전 조회 4,525
13년 전 조회 3,221
13년 전 조회 4,389
13년 전 조회 2,218
13년 전 조회 1,409
13년 전 조회 1,083
13년 전 조회 2,200
13년 전 조회 5,142
13년 전 조회 1,418
13년 전 조회 4,258
13년 전 조회 5,776
13년 전 조회 1,409
13년 전 조회 2,684
13년 전 조회 1,789
13년 전 조회 761
13년 전 조회 2,460
13년 전 조회 2,209
13년 전 조회 908
13년 전 조회 846
13년 전 조회 3,346
13년 전 조회 1,761
13년 전 조회 785
13년 전 조회 621
13년 전 조회 8,271
13년 전 조회 4,769
13년 전 조회 7,962
13년 전 조회 915
13년 전 조회 1,556
13년 전 조회 1,966
13년 전 조회 1,374
13년 전 조회 2,870
13년 전 조회 1,077
13년 전 조회 1,292
13년 전 조회 778
13년 전 조회 1,301
13년 전 조회 1,502
13년 전 조회 1.3만
13년 전 조회 1,222
13년 전 조회 4,755
13년 전 조회 1,730
13년 전 조회 768
13년 전 조회 1,070
13년 전 조회 3,885
13년 전 조회 1,054
13년 전 조회 4,703
13년 전 조회 800
13년 전 조회 956
13년 전 조회 1,363
13년 전 조회 8,893
13년 전 조회 1,599
13년 전 조회 2,648
13년 전 조회 1,803
13년 전 조회 2,044
13년 전 조회 2,137
13년 전 조회 1,212
13년 전 조회 1,403
13년 전 조회 1.8만
13년 전 조회 2,451
13년 전 조회 4,490
13년 전 조회 1,822
13년 전 조회 2,228
13년 전 조회 2,290
13년 전 조회 1.6만
13년 전 조회 1,213
13년 전 조회 1,060
13년 전 조회 844
13년 전 조회 1,733
13년 전 조회 3,329
13년 전 조회 3,557
13년 전 조회 2,248
13년 전 조회 5,793
13년 전 조회 2,946
13년 전 조회 6,147
13년 전 조회 1,758
13년 전 조회 2.1만
13년 전 조회 1,047
13년 전 조회 1,532
13년 전 조회 1.7만
13년 전 조회 2,908
13년 전 조회 1,158
13년 전 조회 3,876
13년 전 조회 1,324
13년 전 조회 1,468
13년 전 조회 913
13년 전 조회 2,651
13년 전 조회 1,642
13년 전 조회 789
13년 전 조회 1,040
13년 전 조회 7,597
🐛 버그신고