duanruoyu6675
2013-07-14 00:35
浏览 81
已采纳

从3个可能的列中选择,按出现/相关性排序

I have a table that contains 3 text fields, and an ID one.

The table exists solely to get collection of ID's of posts based on relevance of a user search.

Problem is I lack the Einsteinian intellect necessary to warp the SQL continuum to get the desired results -

SELECT `id` FROM `wp_ss_images` WHERE `keywords` LIKE '%cute%' OR `title` LIKE '%cute%' OR `content` LIKE '%cute%'
  • Is this really enough to get a relevant-to-least-relevant list, or is there a better way?

Minding of course databases could be up to 20k rows, I want to keep it efficient.


Here is an update - I've gone the fulltext route -

EXAMPLE:

SELECT `id` FROM `wp_ss_images` WHERE MATCH (`keywords`,`title`,`content`) AGAINST ('+cute +dog' IN BOOLEAN MODE);

However it seems to be just grabbing all entries with any of the words. How can I refine this to show relevance by occurances?

图片转代码服务由CSDN问答提供 功能建议

我有一个包含3个文本</ strong>字段和一个ID的表。</ p>

该表仅用于根据用户搜索的相关性收集帖子的ID。 </ p>

问题是我缺乏必要的爱因斯坦智力来扭曲SQL连续体以获得所需的结果 - </ p>

  SELECT`id` FROM`  wp_ss_images` WHERE` keywords` LIKE'%cute%'或`title` LIKE'%cute%'或``content` LIKE'%cute%'
 </ code> </ pre> 
 
 
    \ n
  • 这真的足以获得相关至少相关的列表,还是有更好的方法?</ li> </ ul>

    当然,数据库可能是 高达20k行,我想保持高效。 </ p>


    这是一个更新 - 我已经走了全文路线 - </ p>

    示例:</ p>

      SELECT`id` FROM`wp_ss_images` WHERE MATCH(`keywords`,`title`,`content`)AGAINST('+ cute + dog'IN BOOLEAN MODE); 
     </ code>  </ pre> 
     
     

    然而,它似乎只是用任何一个词来抓取所有条目。 如何通过出现来改进它以显示相关性?</ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题