mysql like 검색방법

· 13년 전 · 4622 · 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년 전 조회 710
13년 전 조회 6,251
13년 전 조회 702
13년 전 조회 891
13년 전 조회 651
13년 전 조회 796
13년 전 조회 1,141
13년 전 조회 993
13년 전 조회 1,093
13년 전 조회 3,661
13년 전 조회 2,137
13년 전 조회 4,391
13년 전 조회 3,085
13년 전 조회 4,267
13년 전 조회 2,084
13년 전 조회 1,283
13년 전 조회 936
13년 전 조회 2,082
13년 전 조회 5,011
13년 전 조회 1,284
13년 전 조회 4,122
13년 전 조회 5,651
13년 전 조회 1,285
13년 전 조회 2,547
13년 전 조회 1,654
13년 전 조회 623
13년 전 조회 2,336
13년 전 조회 2,084
13년 전 조회 774
13년 전 조회 721
13년 전 조회 3,210
13년 전 조회 1,630
13년 전 조회 646
13년 전 조회 505
13년 전 조회 8,141
13년 전 조회 4,638
13년 전 조회 7,836
13년 전 조회 786
13년 전 조회 1,422
13년 전 조회 1,841
13년 전 조회 1,242
13년 전 조회 2,741
13년 전 조회 956
13년 전 조회 1,166
13년 전 조회 656
13년 전 조회 1,185
13년 전 조회 1,372
13년 전 조회 1.3만
13년 전 조회 1,095
13년 전 조회 4,623
13년 전 조회 1,599
13년 전 조회 648
13년 전 조회 937
13년 전 조회 3,745
13년 전 조회 925
13년 전 조회 4,579
13년 전 조회 665
13년 전 조회 830
13년 전 조회 1,236
13년 전 조회 8,761
13년 전 조회 1,478
13년 전 조회 2,509
13년 전 조회 1,658
13년 전 조회 1,922
13년 전 조회 2,008
13년 전 조회 1,076
13년 전 조회 1,267
13년 전 조회 1.8만
13년 전 조회 2,330
13년 전 조회 4,357
13년 전 조회 1,684
13년 전 조회 2,109
13년 전 조회 2,160
13년 전 조회 1.6만
13년 전 조회 1,079
13년 전 조회 937
13년 전 조회 725
13년 전 조회 1,621
13년 전 조회 3,201
13년 전 조회 3,451
13년 전 조회 2,122
13년 전 조회 5,657
13년 전 조회 2,814
13년 전 조회 6,024
13년 전 조회 1,637
13년 전 조회 2.1만
13년 전 조회 907
13년 전 조회 1,401
13년 전 조회 1.7만
13년 전 조회 2,786
13년 전 조회 1,028
13년 전 조회 3,741
13년 전 조회 1,192
13년 전 조회 1,348
13년 전 조회 791
13년 전 조회 2,524
13년 전 조회 1,516
13년 전 조회 662
13년 전 조회 907
13년 전 조회 7,472
🐛 버그신고