SQL复数/单数搜索 [英] SQL plural/singular searches

查看:355
本文介绍了SQL复数/单数搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如:如果一个人搜索男士戒指,我该如何检查数据库以查看如果任何字段中包含男士,男士,男士,戒指,戒指等? 解决方案

使用LIKE将是您需要的最佳方法。我会研究MySQL FULLTEXT索引来获得基本的功能。我将不得不多看看复数的东西,看看是否可以完成。



查看这两个链接以获得FULLTEXT索引信息。

p>



以下是第二篇文章的摘录:

  SELECT标题,故事FROM新闻
匹配(标题,故事)反对('Hurricane');

更新:

我发现这个SO帖子,其中的评论似乎表明FULLTEXT索引将采用复数形式和语法形式,但他没有引用一个资料来源,所以我很难肯定地说。你可以试试FULLTEXT索引方法吗?


How can I make plural/singular words pull all forms?

Example: If a person searches for "mens rings" how can I check the data base to see if any of the fields contain mens, men, men's, ring, rings, etc.?

解决方案

It dosn't seem that using LIKE would be the best approach for what you need. I would look into MySQL FULLTEXT indexing to get the basic functionality working. I'll have to look into the plural thing a bit more to see if that can be accomplished.

Take a look at these two links for FULLTEXT indexing info.

Here is a snippet from the second article:

SELECT headline, story FROM news
WHERE MATCH (headline,story) AGAINST ('Hurricane');

UPDATE:

I found this SO post in which a comment seems to suggest that the FULLTEXT indexing will take plural and grammatical forms into account but he dosn't cite a source, so it's hard for me to say for sure. Can you try the FULLTEXT indexing method?

这篇关于SQL复数/单数搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆