컴

mysql like 검색방법

· 2012-12-02 (일) 12:52:59 · 7378 · 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,188건
+
제목 글쓴이 날짜 조회
13-03-03 조회 6,212
13-03-01 조회 5,544
13-03-01 조회 8,280
13-03-01 조회 6,253
13-02-26 조회 3,860
13-02-26 조회 3,820
13-02-26 조회 4,710
13-02-24 조회 8,148
13-02-24 조회 4,227
13-02-24 조회 3,474
13-02-24 조회 5,279
13-02-24 조회 5,282
13-02-24 조회 4,349
13-02-24 조회 5,687
13-02-24 조회 9,372
13-02-14 조회 5,068
13-02-13 조회 8,989
13-01-29 조회 7,642
13-01-24 조회 4,996
13-01-24 조회 4,872
13-01-17 조회 4,272
13-01-16 조회 4,291
13-01-08 조회 4,372
12-12-27 조회 4,025
12-12-20 조회 1.1만
12-12-20 조회 3,350
12-12-06 조회 4,336
12-12-01 조회 4,074
12-11-28 조회 5,650
12-11-25 조회 5,359
12-10-20 조회 4,631
12-10-03 조회 4,781
12-09-26 조회 4,972
12-09-15 조회 8,416
12-09-14 조회 5,435
12-09-11 조회 3,921
12-09-10 조회 3,958
12-09-05 조회 8,831
12-08-29 조회 4,602
12-08-26 조회 3,748
12-08-23 조회 3,456
12-08-22 조회 3,525
12-08-22 조회 4,342
12-08-21 조회 3,494
12-08-20 조회 3,420
12-08-20 조회 9,227
12-08-15 조회 4,340
12-08-13 조회 3,254
12-08-11 조회 4,667
12-08-05 조회 4,524
12-08-03 조회 3,304
12-08-03 조회 3,992
12-08-02 조회 4,979
12-07-29 조회 4,086
12-07-26 조회 3,674
12-07-26 조회 3,545
12-07-22 조회 3,451
12-07-20 조회 3,286
12-07-19 조회 4,153
12-07-19 조회 3,410
12-07-16 조회 3,534
12-07-16 조회 4,449
12-07-15 조회 3,506
12-07-12 조회 7,353
12-07-12 조회 5,001
12-07-11 조회 3,030
12-07-09 조회 3,201
12-07-05 조회 3,810
12-07-04 조회 4,390
12-07-04 조회 3,793
12-07-04 조회 4,328
12-06-29 조회 3,772
12-06-27 조회 3,359
12-06-24 조회 3,830
12-06-22 조회 4,140
12-06-22 조회 8,561
12-06-22 조회 3,214
12-06-21 조회 3,234
12-06-17 조회 3,862
12-06-14 조회 3,962
12-06-14 조회 3,246
12-06-08 조회 4,405
12-06-06 조회 3,355
12-06-04 조회 4,106
12-05-26 조회 4,950
12-05-26 조회 3,898
12-05-25 조회 3,187
12-05-24 조회 3,289
12-05-22 조회 3,328
12-05-20 조회 2,964
12-05-16 조회 3,107
12-05-15 조회 3,502
12-05-10 조회 3,936
12-05-08 조회 3,450
12-05-04 조회 3,300
12-05-03 조회 4,242
12-05-02 조회 3,397
12-05-02 조회 3,151
12-05-02 조회 3,263
12-04-26 조회 3,411