RE: [PHP-DB] How to return records in _random_ order ???
| From: | John W. Holmes | Date: | Tue, 17 Dec 2002 04:57:09 +0000 |
| Subject: | RE: [PHP-DB] How to return records in _random_ order ??? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-24203@lists.php.net to get a copy of this message | ||
> I need to...
>
> 1 - Select a set of records from a db
>
> 2 - Return a list of one or two fields from the selected record set in
> random order on a web page.
>
> Once I have my selected records & fields... say I end up with 20
records
> after my select query...
>
> How can I return the selected records in _random_ order ??
With mysql...
SELECT * FROM your_table ORDER BY RAND() LIMIT 20
Will return 20 random rows from your table.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/