mysql like 검색방법

· 13년 전 · 4745 · 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년 전 조회 835
13년 전 조회 6,384
13년 전 조회 843
13년 전 조회 1,025
13년 전 조회 767
13년 전 조회 931
13년 전 조회 1,264
13년 전 조회 1,121
13년 전 조회 1,229
13년 전 조회 3,799
13년 전 조회 2,274
13년 전 조회 4,520
13년 전 조회 3,212
13년 전 조회 4,385
13년 전 조회 2,215
13년 전 조회 1,404
13년 전 조회 1,077
13년 전 조회 2,197
13년 전 조회 5,139
13년 전 조회 1,412
13년 전 조회 4,253
13년 전 조회 5,775
13년 전 조회 1,403
13년 전 조회 2,675
13년 전 조회 1,783
13년 전 조회 757
13년 전 조회 2,459
13년 전 조회 2,202
13년 전 조회 904
13년 전 조회 841
13년 전 조회 3,342
13년 전 조회 1,759
13년 전 조회 779
13년 전 조회 615
13년 전 조회 8,266
13년 전 조회 4,766
13년 전 조회 7,959
13년 전 조회 913
13년 전 조회 1,548
13년 전 조회 1,962
13년 전 조회 1,374
13년 전 조회 2,867
13년 전 조회 1,073
13년 전 조회 1,287
13년 전 조회 775
13년 전 조회 1,299
13년 전 조회 1,498
13년 전 조회 1.3만
13년 전 조회 1,216
13년 전 조회 4,746
13년 전 조회 1,723
13년 전 조회 762
13년 전 조회 1,069
13년 전 조회 3,878
13년 전 조회 1,051
13년 전 조회 4,702
13년 전 조회 794
13년 전 조회 950
13년 전 조회 1,360
13년 전 조회 8,888
13년 전 조회 1,595
13년 전 조회 2,642
13년 전 조회 1,794
13년 전 조회 2,039
13년 전 조회 2,131
13년 전 조회 1,208
13년 전 조회 1,399
13년 전 조회 1.8만
13년 전 조회 2,450
13년 전 조회 4,489
13년 전 조회 1,815
13년 전 조회 2,225
13년 전 조회 2,286
13년 전 조회 1.6만
13년 전 조회 1,207
13년 전 조회 1,051
13년 전 조회 840
13년 전 조회 1,730
13년 전 조회 3,322
13년 전 조회 3,553
13년 전 조회 2,245
13년 전 조회 5,785
13년 전 조회 2,941
13년 전 조회 6,143
13년 전 조회 1,756
13년 전 조회 2.1만
13년 전 조회 1,043
13년 전 조회 1,530
13년 전 조회 1.7만
13년 전 조회 2,901
13년 전 조회 1,154
13년 전 조회 3,866
13년 전 조회 1,319
13년 전 조회 1,465
13년 전 조회 910
13년 전 조회 2,647
13년 전 조회 1,639
13년 전 조회 781
13년 전 조회 1,034
13년 전 조회 7,589
🐛 버그신고