RE: How to return records in _random_ order ???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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/



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux