mysql like 검색방법

· 13년 전 · 4797 · 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년 전 조회 873
13년 전 조회 6,407
13년 전 조회 878
13년 전 조회 1,073
13년 전 조회 818
13년 전 조회 966
13년 전 조회 1,307
13년 전 조회 1,166
13년 전 조회 1,255
13년 전 조회 3,838
13년 전 조회 2,306
13년 전 조회 4,571
13년 전 조회 3,250
13년 전 조회 4,427
13년 전 조회 2,246
13년 전 조회 1,439
13년 전 조회 1,118
13년 전 조회 2,240
13년 전 조회 5,166
13년 전 조회 1,447
13년 전 조회 4,290
13년 전 조회 5,813
13년 전 조회 1,464
13년 전 조회 2,720
13년 전 조회 1,828
13년 전 조회 788
13년 전 조회 2,498
13년 전 조회 2,247
13년 전 조회 942
13년 전 조회 890
13년 전 조회 3,379
13년 전 조회 1,791
13년 전 조회 815
13년 전 조회 666
13년 전 조회 8,310
13년 전 조회 4,806
13년 전 조회 7,995
13년 전 조회 959
13년 전 조회 1,597
13년 전 조회 1,999
13년 전 조회 1,403
13년 전 조회 2,901
13년 전 조회 1,121
13년 전 조회 1,321
13년 전 조회 817
13년 전 조회 1,336
13년 전 조회 1,536
13년 전 조회 1.3만
13년 전 조회 1,261
13년 전 조회 4,798
13년 전 조회 1,765
13년 전 조회 805
13년 전 조회 1,109
13년 전 조회 3,919
13년 전 조회 1,085
13년 전 조회 4,738
13년 전 조회 830
13년 전 조회 992
13년 전 조회 1,408
13년 전 조회 8,934
13년 전 조회 1,635
13년 전 조회 2,684
13년 전 조회 1,831
13년 전 조회 2,084
13년 전 조회 2,175
13년 전 조회 1,248
13년 전 조회 1,437
13년 전 조회 1.8만
13년 전 조회 2,491
13년 전 조회 4,521
13년 전 조회 1,845
13년 전 조회 2,265
13년 전 조회 2,323
13년 전 조회 1.6만
13년 전 조회 1,252
13년 전 조회 1,092
13년 전 조회 891
13년 전 조회 1,775
13년 전 조회 3,360
13년 전 조회 3,588
13년 전 조회 2,284
13년 전 조회 5,826
13년 전 조회 2,971
13년 전 조회 6,182
13년 전 조회 1,804
13년 전 조회 2.1만
13년 전 조회 1,077
13년 전 조회 1,571
13년 전 조회 1.7만
13년 전 조회 2,940
13년 전 조회 1,198
13년 전 조회 3,912
13년 전 조회 1,361
13년 전 조회 1,503
13년 전 조회 950
13년 전 조회 2,689
13년 전 조회 1,670
13년 전 조회 828
13년 전 조회 1,070
13년 전 조회 7,636
🐛 버그신고