mysql like 검색방법

· 13년 전 · 4806 · 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년 전 조회 880
13년 전 조회 6,416
13년 전 조회 886
13년 전 조회 1,080
13년 전 조회 831
13년 전 조회 967
13년 전 조회 1,314
13년 전 조회 1,175
13년 전 조회 1,262
13년 전 조회 3,843
13년 전 조회 2,315
13년 전 조회 4,579
13년 전 조회 3,260
13년 전 조회 4,436
13년 전 조회 2,260
13년 전 조회 1,452
13년 전 조회 1,125
13년 전 조회 2,247
13년 전 조회 5,180
13년 전 조회 1,453
13년 전 조회 4,296
13년 전 조회 5,824
13년 전 조회 1,476
13년 전 조회 2,731
13년 전 조회 1,833
13년 전 조회 790
13년 전 조회 2,512
13년 전 조회 2,255
13년 전 조회 947
13년 전 조회 900
13년 전 조회 3,387
13년 전 조회 1,800
13년 전 조회 825
13년 전 조회 672
13년 전 조회 8,320
13년 전 조회 4,817
13년 전 조회 8,009
13년 전 조회 964
13년 전 조회 1,603
13년 전 조회 2,012
13년 전 조회 1,410
13년 전 조회 2,911
13년 전 조회 1,128
13년 전 조회 1,327
13년 전 조회 826
13년 전 조회 1,345
13년 전 조회 1,545
13년 전 조회 1.3만
13년 전 조회 1,271
13년 전 조회 4,807
13년 전 조회 1,780
13년 전 조회 817
13년 전 조회 1,115
13년 전 조회 3,924
13년 전 조회 1,093
13년 전 조회 4,743
13년 전 조회 836
13년 전 조회 996
13년 전 조회 1,416
13년 전 조회 8,945
13년 전 조회 1,648
13년 전 조회 2,692
13년 전 조회 1,840
13년 전 조회 2,088
13년 전 조회 2,183
13년 전 조회 1,255
13년 전 조회 1,447
13년 전 조회 1.8만
13년 전 조회 2,499
13년 전 조회 4,527
13년 전 조회 1,854
13년 전 조회 2,275
13년 전 조회 2,332
13년 전 조회 1.6만
13년 전 조회 1,260
13년 전 조회 1,102
13년 전 조회 903
13년 전 조회 1,787
13년 전 조회 3,375
13년 전 조회 3,598
13년 전 조회 2,297
13년 전 조회 5,836
13년 전 조회 2,983
13년 전 조회 6,195
13년 전 조회 1,808
13년 전 조회 2.1만
13년 전 조회 1,086
13년 전 조회 1,582
13년 전 조회 1.7만
13년 전 조회 2,948
13년 전 조회 1,200
13년 전 조회 3,919
13년 전 조회 1,368
13년 전 조회 1,511
13년 전 조회 959
13년 전 조회 2,698
13년 전 조회 1,681
13년 전 조회 836
13년 전 조회 1,082
13년 전 조회 7,649
🐛 버그신고