컴

mysql like 검색방법

· 2012-12-02 (일) 12:52:59 · 7403 · 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-07-14 조회 5,461
13-07-14 조회 5,422
13-07-14 조회 4,713
13-07-14 조회 4,320
13-07-14 조회 4,183
13-07-14 조회 4,240
13-07-14 조회 4,968
13-07-14 조회 4,644
13-07-14 조회 4,391
13-07-14 조회 5,426
13-07-14 조회 5,327
13-07-14 조회 5,094
13-07-14 조회 4,817
13-07-14 조회 5,505
13-07-13 조회 3,770
13-07-01 조회 5,773
13-07-01 조회 5,856
13-07-01 조회 3,958
13-07-01 조회 5,450
13-05-27 조회 4,017
13-05-21 조회 5,063
13-05-02 조회 1만
13-04-29 조회 5,260
13-04-15 조회 5,509
13-04-13 조회 6,446
13-02-27 조회 4,139
13-02-26 조회 6,528
13-02-12 조회 5,295
13-02-01 조회 2.3만
13-01-23 조회 3,580
13-01-09 조회 8,062
13-01-07 조회 4,975
13-01-07 조회 3,725
13-01-04 조회 1.3만
13-01-03 조회 1.2만
12-12-31 조회 6,415
12-12-27 조회 4,548
12-12-27 조회 4,231
12-12-27 조회 8,905
12-12-18 조회 3,722
12-12-12 조회 3,752
12-12-12 조회 6,789
12-12-12 조회 8,203
12-12-05 조회 5,493
12-12-01 조회 6,805
12-11-22 조회 4,711
12-11-09 조회 5,562
12-11-09 조회 7,627
12-10-29 조회 4,835
12-10-16 조회 6,383
12-10-09 조회 5,453
12-09-02 조회 4,564
12-09-01 조회 3,673
12-08-30 조회 4,332
12-08-30 조회 4,327
12-08-28 조회 3,667
12-08-21 조회 7,240
12-08-20 조회 3,764
12-08-18 조회 5,181
12-08-18 조회 3,554
12-08-11 조회 3,704
12-08-09 조회 3,876
12-08-07 조회 3,855
12-08-07 조회 4,432
12-08-01 조회 4,693
12-08-01 조회 4,582
12-07-20 조회 9,938
12-07-17 조회 4,301
12-07-15 조회 4,056
12-07-10 조회 4,327
12-07-09 조회 7,039
12-07-05 조회 3,373
12-07-04 조회 3,533
12-06-30 조회 5,768
12-06-28 조회 3,869
12-06-20 조회 4,026
12-06-16 조회 3,330
12-06-14 조회 3,978
12-06-07 조회 4,001
12-06-06 조회 6,362
12-05-27 조회 4,579
12-05-25 조회 3,331
12-05-25 조회 3,151
12-05-24 조회 3,270
12-05-24 조회 4,617
12-05-23 조회 3,996
12-05-22 조회 6,606
12-05-15 조회 4,139
12-05-15 조회 3,687
12-05-14 조회 3,127
12-05-12 조회 3,576
12-05-11 조회 7,078
12-05-07 조회 4,510
12-04-28 조회 3,709
12-04-25 조회 5,365
12-04-15 조회 3,942
12-04-12 조회 4,788
12-04-11 조회 3,548
12-04-08 조회 3,403
12-03-21 조회 6,445