Jump to content

Order by relevance using boolean fulltext search + rand() for rest columns


shalu

Recommended Posts

I am using MYSQL ,MYISAM table type and php version 5.4.16 and am doing a fulltext search based on the (product_name) column and i want to randomize the result of rest of the columns but the problem is rand()not giving the random values.

 

I tried something like this:

 

 

SELECT `product_name`,`main_cat_id`,`sub_cat_id`,`prod_cat_id`,`prod_short_desc`,`com_id`,`product_id`,product_ratings, `min_order_quantity`, `fob`,`country_id`,`company_name`,`attributes`,`attr_values`,`verify`,`image`,product_additionals , MATCH (`product_name`)AGAINST ('"girls top"'IN BOOLEAN MODE) AS relevance, MATCH (`product_name`)AGAINST ('girl* +top*'IN BOOLEAN MODE) AS relevance1 FROM pep_browse_com_prods WHERE (MATCH (`product_name`) AGAINST ('"girls top"'IN BOOLEAN MODE) OR MATCH (`product_name`) AGAINST ('girl* +top*'IN BOOLEAN MODE)) AND STATUS = '0' AND display = '0' ORDER BY relevance DESC,relevance1 DESC,RAND() limit 20;

 

 

I want to set the relevance first then i want the random values of rest columns.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.