...

View Full Version : random selection out of MySQL results



axeldrummer
09-13-2005, 10:32 AM
Hello,

I'm trying to do a random selection out of a MySQL query with a specific conditional. Example: I have a table that has an item id and the price for each item. I query for all items over a certain price and it returns a series of ids that fit that criteria. Then I need to randomly choose from these returned ids in order to display a random item with that criteria. Any methods or suggestions on how to specifically implement this would be greatly appreciated!

Thanks, Jay

Nightfire
09-13-2005, 11:15 AM
mysql_query("SELECT product FROM table WHERE id='id_number' ORDER BY RAND() LIMIT 1")

Give that a try



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum