English 中文(简体)
MySQL 等等效比与 vachars 和 literal 和 literal 的比较 -- -- 自动裁剪不区分大小
原标题:MySQL equivalance comparison with varchars and literals -- not case sensitive with auto-trimming

我正在做一些查询调试,发现我在将华尔士场与字面比较时, 出乎意料(虽然显然是正确的)TRUEs。 具体如下:

  • the row in question is just an auto-increment int primary key, and a varchar(255)
  • to set up add a single row: insert into comp_test(test_string) values( TestString );
  • where test_string= tESTsTRING clause is true
  • where test_string= TestString clause is true (it s padded with blank space at the end)

因此,在构建我的问题时,我可以跨过一个类似的 < a href=>“https://stackoverflow.com/ questions/5629111/mysql-case-sindic-string-comparisson>>,描述原因和如何强迫案件敏感化(与BINARY和COLLATE等组织一起 ) 。 BINARY 和 COLLATE 解决方案是否还会导致空白布板使条款错误?

我现在有部分解决方案,但谁能解释对应比的比较为何如此草率?在以上的例子中,如果测试字符串中的值是8字符串,则有~64000字节可以使比较与真实相比。这算什么等比?似乎是错误的,几乎所有其他语言都不允许任何东西,只有1到1等同。

提前感谢。

最佳回答

尽管C和FORTRAN等古老语言的行为,以及Oracle等古老的DMBS系统,MySQL的内置字符串校对系统允许终端用户指定特定语言的校对规则。 (顺便提一下, Java和DotNet等系统中的字符串处理方法。 )

这是一个非常酷的功能。 它让您通过不同语言的 适当字母( ) 规则来命令您使用 。

您可以发布此搜索条款, 以获得您想要的匹配 。

WHERE BINARY test_string =  TestString  

WHERE test_string =  TestString   COLLATE utf8_bin

WHERE test_string =  TestString   COLLATE utf8_swedish_ci

if your data happen to be in Swedish and st或ed in the UTF8 character set.

http://dev.mysql.com/doc/refman/5.5/en/charset-collate.html' rel=“nofollow'>http://dev.mysql.com/doc/refman/5.5/en/charset-collate.html

But you need to be careful with this. If you ask f或 a collation in a WHERE clause that doesn t match the collation in the table, your SQL may run inefficiently.

It s best to declare your columns with the c或rect character set and collation. If you do that then your tables indexes will be set up to grab the data you need quickly. If your data really are binary data (only you know that) you can declare the table, 或 the column, with the

  COLLATE BIN

修饰者

This part of MySQL is w或th your eff或t to figure out.

问题回答

暂无回答




相关问题
Simple JAVA: Password Verifier problem

I have a simple problem that says: A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string ...

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

String initialization with pair of iterators

I m trying to initialize string with iterators and something like this works: ifstream fin("tmp.txt"); istream_iterator<char> in_i(fin), eos; //here eos is 1 over the end string s(in_i, ...

break a string in parts

I have a string "pc1|pc2|pc3|" I want to get each word on different line like: pc1 pc2 pc3 I need to do this in C#... any suggestions??

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签