Is there a way to force case sensitivity in MySQL / Rails for a single find?

后端 未结 3 1719
离开以前
离开以前 2021-02-09 02:11

I\'m doing some searching of tags, and some users like \"cat\" while others like \"Cat\" Go figure...

Anyways, is there a way to force a particular find to be case sens

3条回答
  •  隐瞒了意图╮
    2021-02-09 02:43

    You can also do a case-sensitive search without changing your column properties.

    SELECT * FROM mytable WHERE myfield='Value' 
    

    This query matches:

    • Value
    • value
    • VALUE
    • vAlUe
    • and so on

    While...

    SELECT * FROM mytable WHERE BINARY myfield='Value'
    

    Matches only:

    • Value

提交回复
热议问题