mysql like 검색방법

· 13년 전 · 4772 · 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년 전 조회 852
13년 전 조회 6,391
13년 전 조회 856
13년 전 조회 1,048
13년 전 조회 788
13년 전 조회 949
13년 전 조회 1,286
13년 전 조회 1,138
13년 전 조회 1,244
13년 전 조회 3,816
13년 전 조회 2,289
13년 전 조회 4,546
13년 전 조회 3,236
13년 전 조회 4,404
13년 전 조회 2,228
13년 전 조회 1,424
13년 전 조회 1,096
13년 전 조회 2,211
13년 전 조회 5,153
13년 전 조회 1,426
13년 전 조회 4,269
13년 전 조회 5,788
13년 전 조회 1,428
13년 전 조회 2,694
13년 전 조회 1,807
13년 전 조회 771
13년 전 조회 2,476
13년 전 조회 2,224
13년 전 조회 919
13년 전 조회 867
13년 전 조회 3,358
13년 전 조회 1,766
13년 전 조회 796
13년 전 조회 640
13년 전 조회 8,286
13년 전 조회 4,779
13년 전 조회 7,977
13년 전 조회 932
13년 전 조회 1,569
13년 전 조회 1,981
13년 전 조회 1,383
13년 전 조회 2,883
13년 전 조회 1,098
13년 전 조회 1,302
13년 전 조회 797
13년 전 조회 1,313
13년 전 조회 1,513
13년 전 조회 1.3만
13년 전 조회 1,235
13년 전 조회 4,773
13년 전 조회 1,742
13년 전 조회 784
13년 전 조회 1,084
13년 전 조회 3,897
13년 전 조회 1,069
13년 전 조회 4,719
13년 전 조회 814
13년 전 조회 974
13년 전 조회 1,375
13년 전 조회 8,909
13년 전 조회 1,612
13년 전 조회 2,663
13년 전 조회 1,810
13년 전 조회 2,053
13년 전 조회 2,146
13년 전 조회 1,224
13년 전 조회 1,420
13년 전 조회 1.8만
13년 전 조회 2,466
13년 전 조회 4,502
13년 전 조회 1,830
13년 전 조회 2,247
13년 전 조회 2,305
13년 전 조회 1.6만
13년 전 조회 1,226
13년 전 조회 1,073
13년 전 조회 862
13년 전 조회 1,749
13년 전 조회 3,339
13년 전 조회 3,566
13년 전 조회 2,258
13년 전 조회 5,806
13년 전 조회 2,955
13년 전 조회 6,158
13년 전 조회 1,775
13년 전 조회 2.1만
13년 전 조회 1,054
13년 전 조회 1,543
13년 전 조회 1.7만
13년 전 조회 2,919
13년 전 조회 1,176
13년 전 조회 3,889
13년 전 조회 1,342
13년 전 조회 1,482
13년 전 조회 927
13년 전 조회 2,659
13년 전 조회 1,653
13년 전 조회 802
13년 전 조회 1,050
13년 전 조회 7,611
🐛 버그신고