mysql like 검색방법

· 13년 전 · 4662 · 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년 전 조회 753
13년 전 조회 6,286
13년 전 조회 750
13년 전 조회 932
13년 전 조회 687
13년 전 조회 832
13년 전 조회 1,175
13년 전 조회 1,022
13년 전 조회 1,137
13년 전 조회 3,701
13년 전 조회 2,175
13년 전 조회 4,429
13년 전 조회 3,126
13년 전 조회 4,306
13년 전 조회 2,115
13년 전 조회 1,323
13년 전 조회 982
13년 전 조회 2,115
13년 전 조회 5,046
13년 전 조회 1,312
13년 전 조회 4,161
13년 전 조회 5,683
13년 전 조회 1,325
13년 전 조회 2,586
13년 전 조회 1,695
13년 전 조회 658
13년 전 조회 2,371
13년 전 조회 2,120
13년 전 조회 805
13년 전 조회 761
13년 전 조회 3,249
13년 전 조회 1,658
13년 전 조회 691
13년 전 조회 542
13년 전 조회 8,175
13년 전 조회 4,676
13년 전 조회 7,872
13년 전 조회 819
13년 전 조회 1,457
13년 전 조회 1,874
13년 전 조회 1,277
13년 전 조회 2,787
13년 전 조회 987
13년 전 조회 1,197
13년 전 조회 689
13년 전 조회 1,224
13년 전 조회 1,407
13년 전 조회 1.3만
13년 전 조회 1,133
13년 전 조회 4,663
13년 전 조회 1,640
13년 전 조회 686
13년 전 조회 971
13년 전 조회 3,781
13년 전 조회 955
13년 전 조회 4,615
13년 전 조회 700
13년 전 조회 859
13년 전 조회 1,268
13년 전 조회 8,794
13년 전 조회 1,507
13년 전 조회 2,549
13년 전 조회 1,691
13년 전 조회 1,953
13년 전 조회 2,042
13년 전 조회 1,115
13년 전 조회 1,306
13년 전 조회 1.8만
13년 전 조회 2,362
13년 전 조회 4,393
13년 전 조회 1,723
13년 전 조회 2,148
13년 전 조회 2,193
13년 전 조회 1.6만
13년 전 조회 1,117
13년 전 조회 966
13년 전 조회 758
13년 전 조회 1,646
13년 전 조회 3,236
13년 전 조회 3,470
13년 전 조회 2,156
13년 전 조회 5,685
13년 전 조회 2,841
13년 전 조회 6,059
13년 전 조회 1,663
13년 전 조회 2.1만
13년 전 조회 938
13년 전 조회 1,433
13년 전 조회 1.7만
13년 전 조회 2,816
13년 전 조회 1,060
13년 전 조회 3,772
13년 전 조회 1,223
13년 전 조회 1,378
13년 전 조회 823
13년 전 조회 2,559
13년 전 조회 1,544
13년 전 조회 691
13년 전 조회 944
13년 전 조회 7,506
🐛 버그신고