MySQL 5.1 リファレンスマニュアル :: B Errors, Error Codes, and Common Problems :: B.1 Problems and Common Errors :: B.1.5 Query-Related Issues :: B.1.5.1 Case Sensitivity in Searches
« B.1.5 Query-Related Issues

B.1.5.2 Problems Using DATE Columns »
Section Navigation      [Toggle]
  • B.1.5 Query-Related Issues
  • B.1.5.1 Case Sensitivity in Searches
  • B.1.5.2 Problems Using DATE Columns
  • B.1.5.3 Problems with NULL Values
  • B.1.5.4 Problems with Column Aliases
  • B.1.5.5 Rollback Failure for Non-Transactional Tables
  • B.1.5.6 Deleting Rows from Related Tables
  • B.1.5.7 Solving Problems with No Matching Rows
  • B.1.5.8 Problems with Floating-Point Comparisons

B.1.5.1. Case Sensitivity in Searches

By default, MySQL searches are not case sensitive (although there are some character sets that are never case insensitive, such as czech). This means that if you search with col_name LIKE 'a%', you get all column values that start with A or a. If you want 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. For example:

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

If you want a column always to be treated in case-sensitive fashion, declare it with a case sensitive or binary collation. See 項12.1.8. 「CREATE TABLE 構文」.

Simple comparison operations (>=, >, =, <, <=, sorting, and grouping) are based on each character's 「sort value.」 Characters with the same sort value (such as ‘E’, ‘e’, and ‘é’) are treated as the same character.

Copyright © 1997, 2010, Oracle and/or its affiliates. All rights reserved. Legal Notices
Top / Previous / Next / Up / Table of Contents
© 2010, Oracle Corporation and/or its affiliates