High sensitivity to lowercase letters in MySQL database search

Source: Internet
Author: User

By default, MySQL search is case-insensitive (however, some character sets are always case-sensitive, such as czech ). This means that if you use col_name LIKE 'a % 'for search, you will get all columns starting with a or. If you want to make the search area case sensitive, make sure that one of the operands is case sensitive or binary. For example, if you are comparing columns and strings of the latin1 character set, you can use the COLLATE operator to enable one operand to be proofread by latin1_general_cs or latin1_bin. 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 to always process columns in case sensitive mode, you can declare them using case sensitive or binary checking.

Simple comparison operations (>=, >,=, <,<=, sort and group) are based on the "Sort value" of each character ". Characters with the same sorting value (for example, 'E', 'E', and 'distinct ')©') Will be treated as the same write character.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.