Posted By

LuckyShot on 04/27/10


Tagged

mysql sql


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

d0ri0
t9md
virendrakryadav


MySQL - Most relevant weighted results based (MATCH AGAINST)


 / Published in: MySQL
 

URL: http://xaviesteve.com/category/web-design/mysql/

  1. SELECT *, (
  2. (1.2 * (MATCH(title) AGAINST (`".$keyword."` IN BOOLEAN MODE))) +
  3. (0.8 * (MATCH(description) AGAINST (`+".$keyword."` IN BOOLEAN MODE))) +
  4. (1.0 * (MATCH(tags) AGAINST (`".$keyword."` IN BOOLEAN MODE)))
  5. ) AS relevance
  6. FROM `".$table_posts."`
  7. WHERE
  8. MATCH (title, description, tags) AGAINST ('".$keyword."' IN BOOLEAN MODE)
  9. ORDER BY relevance DESC
  10. LIMIT 0,5

Report this snippet  

You need to login to post a comment.