0

I am using MYSQL MYISAM and php version 5.4.16,MYISAM and am doing a fulltext search based on the (product_name) column and i want to randomize the result 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.

2
Contributors
1
Reply
8
Views
3 Years
Discussion Span
Last Post by minitauros
0

I'm not sure but maybe the RAND() should be something your select returns. Just a piece of thought, though. Something like

SELECT RAND() AS rand_nr
ORDER BY rand_nr DESC

Just a question though: what use does it have to create a random order, after you've already ordered by relevance?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.