修改Mysql表中的字符串搜索
我有一个字符串查询要搜索(假设“这是我的第一个查询”作为示例)。
我还有一个由 (id, title, rating, ...) 属性组成的表。
我想要的是找出与“title”属性匹配的字符串查询的搜索结果(可能或完全两者)。
但是,如果完整的文本(即“这是我的第一个查询”)不存在,那么如果我确实喜欢的话,将不会有结果。
SELECT * FROM test WHERE title LIKE '%$query%';
接下来我想的是用较小的字符触发另一个查询。即我将触发使用搜索字符串“这是我的第一个查询”(y 被截断)进行相同的查询,依此类推,直到得到我想要的编号。结果。
但我的问题是:
- 这是非常昂贵的操作
- 我希望搜索数据按照评级值的降序排序(“测试”表中的另一个字段)
请帮我解决如何继续此操作?
I have a string query to search (assuming "this is my first query" as an example).
And I am also having a table which consists of (id, title, rating, ... ) attributes.
What I want is to find out the search results of my string query which match with "title" attribute (probable or exact both).
But what if complete text i.e. "this is my first query" is not there then there will be no results if I do like
SELECT * FROM test WHERE title LIKE '%$query%';
What I am trying to think next is to fire another query with lesser character this time.. i.e. I will fire the same query using search string "this is my first quer" (y is truncated) and so on until I get my desired no. of results.
But my problem is:
- This is very costly operation
- I want search data to be sorted in order of descending value of rating ( another field in "test" table)
Please help me out how can I proceed with this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)