I have a varchar field in my database which i use for two significantly different things. In one scenario i use it for evaluating with case sensitivity to ensure no duplicates are inserted. To achieve this I’ve set the comparison to binary. However, I want to be able to search case-insensitively on the same column values. Is there any way I can do this without simply creating a redundant column with collation instead of binary?
Share
The second query will return both rows.
Note, however, that anything with
COLLATEapplied to it has the lowest coercibility.This means that it’s
valuethat will be converted toUTF8_GENERAL_CIfor the comparision purposes, not the other way round, which means that the index onvaluewill not be used for searching and the condition in the query will be not sargable.If you need good performance on case-insensitive searching, you should create an additional column with case-insensitive collation, index it and use in the searches.