컴

mysql like 검색방법

· 2012-12-02 (일) 12:52:59 · 7244 · 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개

2012-12-02 (일) 13:00:46
감사요
ㅎ 그렇군요..
2012-12-08 (토) 19:36:19
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
감사합니다
2012-12-14 (금) 00:53:42
감사합니다
감사합니다
감사합니다
감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
16-07-13 조회 2,067
16-07-12 조회 2,202
16-07-12 조회 2,222
16-07-11 조회 2,104
16-06-05 조회 2,657
16-06-03 조회 2,759
16-05-26 조회 2,716
15-09-22 조회 4,843
15-06-10 조회 4,639
14-10-25 조회 6,077
14-10-22 조회 8,819
14-09-21 조회 5,615
14-09-16 조회 4,910
14-08-22 조회 1만
14-08-13 조회 5,742
14-08-12 조회 5,287
14-08-12 조회 6,150
14-08-11 조회 6,677
14-06-12 조회 6,032
14-06-11 조회 4,887
14-05-09 조회 5,261
14-05-09 조회 6,226
14-05-09 조회 6,238
14-05-08 조회 5,570
14-04-17 조회 4,548
14-04-16 조회 4,421
14-04-15 조회 4,392
14-04-15 조회 4,424
14-04-15 조회 4,073
14-04-14 조회 4,124
14-04-14 조회 4,086
14-04-14 조회 4,505
14-04-14 조회 4,512
14-04-14 조회 4,556
14-04-13 조회 4,394
14-04-12 조회 4,100
14-04-12 조회 4,182
14-04-12 조회 4,264
14-04-11 조회 4,779
14-04-10 조회 4,458
14-04-10 조회 4,483
14-04-09 조회 4,759
14-04-09 조회 5,085
14-04-08 조회 6,699
13-10-30 조회 7,507
13-07-11 조회 4,991
13-03-28 조회 1.1만
13-02-27 조회 6,570
13-02-14 조회 5,404
13-01-10 조회 4,399
12-12-31 조회 4,928
12-12-20 조회 6,029
12-12-12 조회 5,165
12-12-07 조회 4,342
12-11-28 조회 4,662
12-11-22 조회 5,125
12-11-12 조회 5,450
12-09-22 조회 4,425
12-09-18 조회 4,611