MySQL Select query case-sensitive three methods (1/3)

Source: Internet
Author: User
Tags character set mysql tutorial

1, one way is to set the table or row collation, so that it is binary or case sensitive. In the MySQL tutorial, the naming method for column collate its conventions is as follows:

*_bin: Binary case sensitive collation, which means case-sensitive.
*_cs:case sensitive collation, case-sensitive
*_ci:case insensitive collation, case-insensitive

###########
# Start Binary Collation example
###########
Mysql> CREATE TABLE case_bin_test (Word varchar) Character Set latin1 collate latin1_bin;
Query OK, 0 rows affected (0.02 sec)

mysql> INSERT into case_bin_test values (' Frank '), (' Google '), (' Froogle '), (' Flickr '), (' Flickr ');
Query OK, 5 rows Affected (0.00 sec)
Records:5 duplicates:0 warnings:0

Mysql> SELECT * from Case_bin_test where word is like ' f% ';
+---------+
| Word |
+---------+
| Froogle |
| Flickr |
+---------+
2 rows in Set (0.00 sec)

Mysql> SELECT * from Case_bin_test where word is like ' f% ';
+---------+
| Word |
+---------+
| Frank |
| Flickr |
+---------+
4 rows in Set (0.00 sec)

###########
# End
###########

home 1 2 3 last
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.