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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.