컴

mysql like 검색방법

· 2012-12-02 (일) 12:52:59 · 7443 · 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건
+
제목 글쓴이 날짜 조회
12-09-05 조회 7,434
12-08-31 조회 5,887
12-08-30 조회 6,651
12-08-22 조회 1.2만
12-08-09 조회 5,670
12-08-02 조회 3,752
12-07-30 조회 4,140
12-07-15 조회 3,756
12-07-10 조회 3,644
12-07-06 조회 3,478
12-07-06 조회 3,462
12-07-03 조회 4,063
12-07-03 조회 3,546
12-07-02 조회 3,440
12-06-25 조회 3,936
12-06-20 조회 3,314
12-06-15 조회 3,896
12-06-14 조회 3,170
12-06-08 조회 3,951
12-06-07 조회 3,942
12-06-05 조회 5,830
12-06-05 조회 3,545
12-06-04 조회 3,901
12-06-01 조회 4,098
12-06-01 조회 4,828
12-06-01 조회 3,693
12-05-30 조회 3,220
12-05-28 조회 3,196
12-05-23 조회 3,310
12-05-18 조회 3,213
12-05-16 조회 3,259
12-05-16 조회 3,233
12-05-16 조회 4,495
12-05-16 조회 3,018
12-05-16 조회 3,013
12-05-16 조회 3,396
12-05-16 조회 3,152
12-05-16 조회 3,050
12-05-15 조회 3,212
12-05-15 조회 2,897
12-05-15 조회 3,143
12-05-15 조회 3,581
12-05-15 조회 3,310
12-05-15 조회 2,689
12-05-14 조회 2,728
12-05-14 조회 2,900
12-05-14 조회 2,867
12-05-14 조회 3,176
12-05-14 조회 3,000
12-05-11 조회 3,292
12-05-11 조회 2,820
12-05-11 조회 2,723
12-05-11 조회 2,824
12-05-11 조회 3,396
12-05-11 조회 2,579
12-05-10 조회 3,981
12-05-10 조회 2,823
12-05-10 조회 2,759
12-05-10 조회 2,897
12-05-10 조회 4,501
12-05-10 조회 2,533
12-05-10 조회 2,631
12-05-10 조회 2,494
12-05-10 조회 2,748
12-05-10 조회 3,205
12-05-10 조회 3,492
12-05-10 조회 2,730
12-05-10 조회 2,851
12-05-10 조회 3,347
12-05-10 조회 2,941
12-05-08 조회 3,126
12-05-08 조회 2,942
12-05-08 조회 2,970
12-05-08 조회 3,358
12-05-08 조회 4,552
12-05-03 조회 2,929
12-05-03 조회 3,026
12-05-03 조회 2,798
12-05-03 조회 3,850
12-05-03 조회 2,894
12-05-02 조회 2,940
12-04-27 조회 2,838
12-04-27 조회 2,901
12-04-27 조회 2,810
12-04-26 조회 2,773
12-04-26 조회 3,129
12-04-26 조회 3,060
12-04-26 조회 2,724
12-04-26 조회 3,050
12-04-26 조회 3,660
12-04-26 조회 2,929
12-04-26 조회 3,594
12-04-26 조회 2,657
12-04-26 조회 2,995
12-04-26 조회 2,725
12-04-26 조회 2,971
12-04-26 조회 2,730
12-04-26 조회 3,159
12-04-26 조회 3,203
12-04-26 조회 3,022