컴

mysql like 검색방법

· 2012-12-02 (일) 12:52:59 · 7416 · 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건
+
제목 글쓴이 날짜 조회
15-12-13 조회 2,531
15-12-13 조회 2,946
15-12-11 조회 2,608
15-12-11 조회 2,569
15-12-11 조회 2,571
15-12-10 조회 2,530
15-12-10 조회 2,588
15-12-10 조회 2,562
15-12-03 조회 3,206
15-12-03 조회 2,720
15-11-25 조회 2,802
15-11-09 조회 3,238
15-11-04 조회 2,971
15-06-09 조회 4,099
15-05-06 조회 5,094
15-03-28 조회 4,624
14-12-05 조회 5,006
14-10-25 조회 5,101
14-10-13 조회 4,278
14-10-03 조회 6,291
14-09-19 조회 4,973
14-09-18 조회 4,055
14-09-13 조회 4,618
14-09-03 조회 5,608
14-08-26 조회 4,214
14-08-26 조회 4,022
14-08-26 조회 3,982
14-08-11 조회 6,534
14-08-06 조회 4,130
14-08-06 조회 3,730
14-08-06 조회 3,945
14-08-01 조회 6,346
14-08-01 조회 3,849
14-07-30 조회 4,448
14-06-28 조회 5,168
14-06-28 조회 4,441
14-05-11 조회 4,593
14-05-09 조회 4,952
14-05-09 조회 7,716
14-04-30 조회 4,343
14-04-27 조회 4,199
14-04-25 조회 4,901
14-04-21 조회 3,879
14-04-21 조회 5,010
14-04-10 조회 4,608
14-04-01 조회 6,162
14-03-03 조회 3,537
14-02-25 조회 5,925
14-02-14 조회 5,198
14-02-13 조회 4,957
14-01-03 조회 4,451
13-12-06 조회 3,771
13-11-22 조회 5,523
13-11-18 조회 4,033
13-10-02 조회 4,449
13-10-02 조회 3,702
13-10-02 조회 3,963
13-10-02 조회 3,818
13-10-02 조회 4,185
13-09-16 조회 8,035
13-09-16 조회 5,400
13-08-18 조회 5,435
13-07-11 조회 4,113
13-07-10 조회 4,697
13-07-09 조회 4,734
13-07-09 조회 4,990
13-07-04 조회 4,489
13-07-04 조회 4,130
13-07-04 조회 4,241
13-07-01 조회 4,729
13-07-01 조회 4,563
13-07-01 조회 6,843
13-06-23 조회 4,389
13-06-05 조회 3,639
13-05-29 조회 4,876
13-05-10 조회 4,286
13-04-05 조회 4,903
13-04-05 조회 6,588
13-04-05 조회 1.1만
13-04-05 조회 7,183
13-04-05 조회 6,570
13-03-31 조회 5,850
13-03-31 조회 4,172
13-03-28 조회 4,533
13-03-28 조회 6,729
13-03-28 조회 9,214
13-03-28 조회 4,346
13-03-24 조회 3,962
13-03-21 조회 4,641
13-03-21 조회 1.8만
13-03-14 조회 3,947
13-03-10 조회 4,755
13-03-10 조회 4,517
13-03-10 조회 4,216
13-03-08 조회 5,273
13-03-08 조회 4,378
13-03-03 조회 5,034
13-03-03 조회 7,491
13-03-03 조회 4,230
13-03-03 조회 1.1만