컴

mysql like 검색방법

· 2012-12-02 (일) 12:52:59 · 7408 · 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건
+
제목 글쓴이 날짜 조회
16-06-03 조회 2,996
15-07-30 조회 3,391
15-06-08 조회 5,542
15-05-27 조회 4,399
15-01-08 조회 6,687
14-12-30 조회 5,417
14-10-10 조회 5,413
14-08-13 조회 6,327
14-08-11 조회 5,187
14-08-06 조회 6,517
14-03-19 조회 7,414
13-04-26 조회 9,576
12-12-15 조회 5,097
12-12-15 조회 7,330
12-12-11 조회 5,459
12-11-21 조회 5,995
12-10-11 조회 5,074
12-10-03 조회 4,770
12-09-20 조회 6,073
12-09-02 조회 4,251
12-08-29 조회 5,248
12-08-29 조회 4,134
12-08-24 조회 4,230
12-08-18 조회 4,457
12-08-17 조회 4,502
12-08-16 조회 3,755
12-08-06 조회 5,528
12-08-05 조회 4,822
12-08-03 조회 4,539
12-08-03 조회 4,678
12-07-29 조회 3,537
12-07-24 조회 4,124
12-07-22 조회 3,598
12-07-20 조회 4,344
12-07-19 조회 4,697
12-07-19 조회 3,924
12-07-19 조회 3,875
12-07-19 조회 5,539
12-07-19 조회 3,484
12-07-18 조회 5,167
12-07-15 조회 4,136
12-07-14 조회 3,820
12-07-12 조회 4,497
12-07-11 조회 3,770
12-07-11 조회 3,492
12-07-11 조회 3,451
12-07-10 조회 4,637
12-07-09 조회 3,392
12-07-09 조회 4,215
12-07-09 조회 4,633
12-07-08 조회 4,553
12-07-07 조회 5,472
12-07-06 조회 4,729
12-07-06 조회 3,999
12-07-06 조회 3,885
12-07-06 조회 3,810
12-07-02 조회 5,492
12-07-02 조회 4,193
12-06-29 조회 3,717
12-06-28 조회 4,346
12-06-26 조회 3,830
12-06-26 조회 4,958
12-06-21 조회 3,932
12-06-20 조회 4,636
12-06-20 조회 4,258
12-06-15 조회 4,618
12-06-15 조회 4,352
12-06-13 조회 7,362
12-06-05 조회 7,344
12-06-04 조회 3,921
12-06-03 조회 3,771
12-05-31 조회 3,775
12-05-28 조회 6,612
12-05-27 조회 3,844
12-05-25 조회 3,986
12-05-23 조회 4,397
12-05-21 조회 5,102
12-05-17 조회 4,045
12-05-17 조회 3,965
12-05-09 조회 4,035
12-05-07 조회 4,285
12-05-02 조회 4,484
12-05-01 조회 4,654
12-04-30 조회 3,403
12-04-30 조회 4,344
12-04-25 조회 4,429
12-04-25 조회 4,859
12-04-24 조회 3,826
12-04-24 조회 4,591
12-04-23 조회 3,595
12-04-20 조회 3,237
12-04-17 조회 5,427
12-04-16 조회 4,369
12-04-14 조회 3,649
12-04-14 조회 3,681
12-04-14 조회 3,730
12-04-13 조회 3,352
12-04-13 조회 4,537
12-04-13 조회 6,175
12-04-12 조회 3,344