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 @".

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

报告相同问题?