Case-sensitive method for MySQL queries

Source: Internet
Author: User


MySQL queries are case-sensitive. Data Storage usually needs to specify the case sensitivity of string fields. MySQL Default queries are case-insensitive. However, as user information, once the user name is repeated, it will waste a lot of resources. In addition, it is difficult to identify the problems caused by the increase of Li Xiao and Li GUI. To do this, either when creating a table, it is case-sensitive (the field is case-sensitive ). If all fields in the overall database need to be case sensitive, it is better to adjust the character set settings. However, this is generally not recommended. If www.2cto.com is the same as me, the database has been running online. If a table contains millions of data records, changing the field type may cause the database to go down. Well, it's better to add more words during the query! For example, general query: the SQL code SELECT * FROM U WHERE name LIKE 'a % '; the result is the same, to distinguish between 'a % 'and 'a %', you can do this: SQL code SELECT * FROM U WHERE binary name LIKE 'a % '; SELECT * from u where binary name LIKE 'a % '; different results can be obtained if only one binary is added! Www.2cto.com, of course, if you need to create a table that is case sensitive, you can write the SQL code create table table_name (name varchar (20) binary); that's so easy!

Related Article

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.