RE: [PHP] retrieving random data from mysql database
| From: | David Freeman | Date: | Sun, 14 Jul 2002 21:46:24 +0000 |
| Subject: | RE: [PHP] retrieving random data from mysql database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-107641@lists.php.net to get a copy of this message | ||
> can you teach me how to retrieve random data from my
> database? like for example...i have a list of names on my
> database and i'd like to retrieve only one name at a
> time..randomly. how do i go about this?
This is really a database question rather than a php question and you
haven't said which database you're using so it's hard to give a
definitive answer. In MySQL you'd do something like this:
Select * from some_table where some_condition order by RAND() limit 1;
That would select one random row out of all rows that meet
"some_condition".
CYA, Dave