mysql like 검색방법

· 13년 전 · 4775 · 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년 전 조회 856
13년 전 조회 6,394
13년 전 조회 858
13년 전 조회 1,051
13년 전 조회 793
13년 전 조회 952
13년 전 조회 1,293
13년 전 조회 1,148
13년 전 조회 1,247
13년 전 조회 3,822
13년 전 조회 2,292
13년 전 조회 4,552
13년 전 조회 3,238
13년 전 조회 4,406
13년 전 조회 2,232
13년 전 조회 1,426
13년 전 조회 1,101
13년 전 조회 2,214
13년 전 조회 5,156
13년 전 조회 1,430
13년 전 조회 4,274
13년 전 조회 5,791
13년 전 조회 1,438
13년 전 조회 2,699
13년 전 조회 1,813
13년 전 조회 773
13년 전 조회 2,481
13년 전 조회 2,229
13년 전 조회 925
13년 전 조회 874
13년 전 조회 3,363
13년 전 조회 1,770
13년 전 조회 800
13년 전 조회 645
13년 전 조회 8,294
13년 전 조회 4,787
13년 전 조회 7,981
13년 전 조회 937
13년 전 조회 1,575
13년 전 조회 1,985
13년 전 조회 1,385
13년 전 조회 2,887
13년 전 조회 1,103
13년 전 조회 1,305
13년 전 조회 806
13년 전 조회 1,318
13년 전 조회 1,516
13년 전 조회 1.3만
13년 전 조회 1,240
13년 전 조회 4,776
13년 전 조회 1,748
13년 전 조회 790
13년 전 조회 1,088
13년 전 조회 3,902
13년 전 조회 1,072
13년 전 조회 4,724
13년 전 조회 818
13년 전 조회 975
13년 전 조회 1,381
13년 전 조회 8,916
13년 전 조회 1,615
13년 전 조회 2,664
13년 전 조회 1,814
13년 전 조회 2,064
13년 전 조회 2,152
13년 전 조회 1,229
13년 전 조회 1,425
13년 전 조회 1.8만
13년 전 조회 2,471
13년 전 조회 4,504
13년 전 조회 1,833
13년 전 조회 2,252
13년 전 조회 2,310
13년 전 조회 1.6만
13년 전 조회 1,234
13년 전 조회 1,078
13년 전 조회 868
13년 전 조회 1,755
13년 전 조회 3,342
13년 전 조회 3,574
13년 전 조회 2,261
13년 전 조회 5,816
13년 전 조회 2,958
13년 전 조회 6,162
13년 전 조회 1,779
13년 전 조회 2.1만
13년 전 조회 1,063
13년 전 조회 1,548
13년 전 조회 1.7만
13년 전 조회 2,925
13년 전 조회 1,180
13년 전 조회 3,895
13년 전 조회 1,345
13년 전 조회 1,487
13년 전 조회 930
13년 전 조회 2,666
13년 전 조회 1,656
13년 전 조회 811
13년 전 조회 1,054
13년 전 조회 7,616
🐛 버그신고