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

后端 未结 3 1721
离开以前
离开以前 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 03:02

    You can make all strings case sensitive when you create the table by adding "COLLATE utf8_bin" to the :options string when creating the table. For example:

    create_table( "page_infos", :force => true, :options => "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin") do |t|
          t.string   "title",       :limit => 120
    end
    

提交回复
热议问题