How to allow fulltext searching with hyphens in the search query

前端 未结 5 452
温柔的废话
温柔的废话 2020-12-03 14:57

I have keywords like \"some-or-other\" where the hyphens matter in the search through my mysql database. I\'m currently using the fulltext function.

Is there a way

5条回答
  •  無奈伤痛
    2020-12-03 15:12

    Maybe simpler to use the Binary operator.

    SELECT * 
    FROM your_table_name 
    WHERE BINARY your_column = BINARY "Foo-Bar%AFK+LOL"
    

    http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#operator_binary

    The BINARY operator casts the string following it to a binary string. This is an easy way to force a column comparison to be done byte by byte rather than character by character. This causes the comparison to be case sensitive even if the column is not defined as BINARY or BLOB. BINARY also causes trailing spaces to be significant.

提交回复
热议问题