[英]MySQL SELECT statement with COLLATE and MATCH
Is there any way to specify COLLATE
and MATCH() AGAINST()
in the same query string. 有什么方法可以在同一查询字符串中指定
COLLATE
和MATCH() AGAINST()
。 I'm trying to get this. 我正在努力做到这一点。
SELECT * FROM table WHERE COLLATE latin1_general_cs MATCH(column) AGAINST('string')
I know that won't work, just an example. 我知道这行不通,只是一个例子。 If
COLLATE
dose not work with MATCH
. 如果
COLLATE
与MATCH
不兼容。 How can I specify the case sensitivity in every query, because I need both case sensitive and case insensitive MATCH() AGAINST()
queries. 如何在每个查询中指定区分大小写,因为我需要区分大小写和不区分大小写的
MATCH() AGAINST()
查询。
No, unfortunately 不,很不幸
Although the use of multiple character sets within a single table is supported, all columns in a FULLTEXT index must use the same character set and collation.
尽管支持在单个表中使用多个字符集,但FULLTEXT索引中的所有列都必须使用相同的字符集和排序规则。
There's no modifier on the full text MATCH() AGAINST
syntax to specify collation. 全文
MATCH() AGAINST
语法上没有修饰符可指定排序规则。
http://dev.mysql.com/doc/refman/5.0/en/fulltext-restrictions.html http://dev.mysql.com/doc/refman/5.0/en/fulltext-restrictions.html
You could maintain a copy of the column
column with a different collation. 您可以使用不同的排序规则维护
column
列的副本。
I figured out how to do this. 我想出了怎么做。 Like @Ollie Jones said, I copied all data it to a new column,with case sensitive collation.
就像@Ollie Jones所说的那样,我将所有数据复制到一个新的列中,并区分大小写。 In my case
latin1_general_cs
. 在我的情况下
latin1_general_cs
。
But because FULLTEXT
indexes can NOT have mixed collation. 但是因为
FULLTEXT
索引不能具有混合排序规则。 There must be 2 FULLTEXT
indexes. 必须有2个
FULLTEXT
索引。 One on the case insensitive column ( latin1_general_ci
)and one on the case sensitive column ( latin1_general_cs
). 一个不区分大小写的列(
latin1_general_ci
),另一个不区分大小写的列( latin1_general_cs
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.