简体   繁体   中英

MySQL SELECT statement with COLLATE and MATCH

Is there any way to specify COLLATE and MATCH() AGAINST() in the same query string. 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 . How can I specify the case sensitivity in every query, because I need both case sensitive and case insensitive MATCH() AGAINST() queries.

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.

There's no modifier on the full text MATCH() AGAINST syntax to specify collation.

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.

I figured out how to do this. Like @Ollie Jones said, I copied all data it to a new column,with case sensitive collation. In my case latin1_general_cs .

But because FULLTEXT indexes can NOT have mixed collation. There must be 2 FULLTEXT indexes. One on the case insensitive column ( latin1_general_ci )and one on the case sensitive column ( latin1_general_cs ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM