컴

mysql like 검색방법

· 2012-12-02 (일) 12:52:59 · 7529 · 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
감사합니다
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,187건
+
제목 글쓴이 날짜 조회
13-02-27 조회 4,169
13-02-27 조회 3,522
13-02-27 조회 6,826
13-02-27 조회 4,221
13-02-26 조회 1.2만
13-02-26 조회 3,717
13-02-26 조회 3,989
13-02-26 조회 6,355
13-02-26 조회 3,943
13-02-26 조회 4,838
13-02-26 조회 6,610
13-02-26 조회 4,109
13-02-25 조회 4,036
13-02-24 조회 8,219
13-02-24 조회 4,323
13-02-24 조회 3,564
13-02-24 조회 5,366
13-02-24 조회 5,354
13-02-24 조회 4,423
13-02-24 조회 5,759
13-02-24 조회 9,452
13-02-24 조회 5,082
13-02-22 조회 3,605
13-02-21 조회 4,750
13-02-21 조회 4,880
13-02-20 조회 5,582
13-02-19 조회 3,453
13-02-19 조회 4,585
13-02-19 조회 3,298
13-02-19 조회 4,929
13-02-18 조회 5,600
13-02-18 조회 3,745
13-02-16 조회 7,010
13-02-15 조회 1.3만
13-02-15 조회 4,303
13-02-15 조회 5,579
13-02-14 조회 5,202
13-02-14 조회 5,678
13-02-13 조회 9,140
13-02-12 조회 5,407
13-02-12 조회 6,086
13-02-12 조회 4,075
13-02-07 조회 3,661
13-02-06 조회 4,725
13-02-05 조회 9,049
13-02-05 조회 4,314
13-02-05 조회 7,742
13-02-04 조회 3,581
13-02-04 조회 7,315
13-02-04 조회 4,255
13-02-03 조회 4,100
13-02-02 조회 4,113
13-02-02 조회 4,216
13-02-01 조회 3,427
13-02-01 조회 3,398
13-02-01 조회 2.4만
13-01-31 조회 3,335
13-01-31 조회 4,079
13-01-30 조회 4,037
13-01-30 조회 4,304
13-01-30 조회 6,452
13-01-30 조회 3,577
13-01-30 조회 5,142
13-01-29 조회 7,752
13-01-28 조회 3,573
13-01-28 조회 6,880
13-01-28 조회 4,106
13-01-28 조회 6,845
13-01-28 조회 3,883
13-01-25 조회 4,957
13-01-25 조회 3,897
13-01-25 조회 5,196
13-01-25 조회 1.1만
13-01-24 조회 4,971
13-01-24 조회 4,849
13-01-24 조회 4,505
13-01-24 조회 3,453
13-01-24 조회 5,095
13-01-24 조회 4,978
13-01-23 조회 3,447
13-01-23 조회 4,124
13-01-23 조회 3,506
13-01-23 조회 3,637
13-01-23 조회 4,255
13-01-22 조회 6,788
13-01-21 조회 5,212
13-01-20 조회 5,291
13-01-20 조회 6,911
13-01-20 조회 6,640
13-01-19 조회 6,351
13-01-19 조회 7,208
13-01-18 조회 3,952
13-01-18 조회 8,979
13-01-18 조회 4,136
13-01-18 조회 4,037
13-01-18 조회 6,256
13-01-18 조회 5,933
13-01-18 조회 8,485
13-01-18 조회 5,815
13-01-18 조회 6,309