How can I make SQL case sensitive string comparison on MySQL?

前端 未结 11 2426
温柔的废话
温柔的废话 2020-11-22 02:45

I have a function that returns five characters with mixed case. If I do a query on this string it will return the value regardless of case.

How can I make MySQL stri

11条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 03:10

    To make use of an index before using the BINARY, you could do something like this if you have large tables.

    SELECT
       *
    FROM
       (SELECT * FROM `table` WHERE `column` = 'value') as firstresult
    WHERE
       BINARY `column` = 'value'
    

    The subquery would result in a really small case-insensitive subset of which you then select the only case-sensitive match.

提交回复
热议问题