pluginbaby Posted August 23, 2006 Share Posted August 23, 2006 I got a question:Imagine this table:id | number1 | 12 | 23 | 34 | 25 | 6now I make a select in php:$str = "select id from table X where number=2 limit 1";$result=mysql_query($str) or die (mysql_error());$line = mysql_fetch_row ($result);$id = $line[0];when I do this, the database selects the first possible id where the number=2.What I want to do is make the database select a random id where the number=2.So it would response with id = 2 sometimes, and other times with id = 4Is this possible? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 23, 2006 Share Posted August 23, 2006 Sure... add an ORDER BY RAND() before the LIMIT clause. Quote Link to comment Share on other sites More sharing options...
pluginbaby Posted August 23, 2006 Author Share Posted August 23, 2006 thank you, I appreciate your help, it works perfectly now ;D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.