doucheng5705 2016-01-25 17:45
浏览 48
已采纳

如何搜索关键字和主题标签或符号?

I have a input box in which user can enter either keyword or #tag word and after click on search button it will find that field which have that keyword or #tags.
1. I tried %like% it worked but if search only for #m it is giving me all words which have m letter.
2. I tried regular expression also like this
WHERE notes REGEXP '[[:<:]]{$f['activityId']}[[:>:]]'
but it is not working for #tag or other symbol.
3. I use also full text search but it is not working for symbol
i refer from here for full text , and i don't want to recompile my mysql.
Full text search

Is there any way to search key word with #tag and with symbol
Like : @amitesh,#amitesh,amitesh etc.

  • 写回答

1条回答 默认 最新

  • dongxiong1941 2016-01-25 21:55
    关注
    mysql> SELECT 'foo #amitesh bar' REGEXP '([[:<:]]|#|@)amitesh[[:>:]]';
    +---------------------------------------------------------+
    | 'foo #amitesh bar' REGEXP '([[:<:]]|#|@)amitesh[[:>:]]' |
    +---------------------------------------------------------+
    |                                                       1 |
    +---------------------------------------------------------+
    

    I think the # and the word start ([[:<:]]) are not playing well together. So, to look for any of @amitesh,#amitesh,amitesh, I decided on "word start OR # OR @".

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

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看