douyu8187 2017-05-07 13:00
浏览 343
已采纳

在mysql全文搜索中搜索特殊字符

I am doing a search function in php, and I am allowing BOOLEAN search, but when I enter text containing chars like @, the query fails.

For example, when I search for @everyone, it throws an error. I tried to solve this by adding doublequotes, but it doesn't work as expected, since for the search @everyone, it works but returns rows containing everyone and @everone.

I would like to know how we can search for words containing special chars in mysql full text search

Here's my query (simplified) :

SELECT * FROM messages WHERE MATCH(body) AGAINST ('@everyone' IN BOOLEAN MODE)
  • 写回答

1条回答 默认 最新

  • douza19870617 2017-05-07 13:06
    关注

    By default, MySQL does not treat '@' as a valid character for a word. If you want to treat '@' it, then review the documentation on the subject.

    After you have made the changes, then you will need to re-build your index.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏