NYCPHP Meetup

NYPHP.org

[nycphp-talk] Need help randomly accessing records from a database

Michael Sims jellicle at gmail.com
Thu Sep 1 09:37:36 EDT 2005


On Thursday 01 September 2005 09:25, Cliff Hirsch wrote:

> I need to randomly access records from a database and have come up with
> the following solution:

> Any ideas?

SELECT field1, field2, rand() AS myrand FROM table ORDER BY myrand LIMIT 1;

It's a common problem.  With a solution that's easy, once you know it.  :)

Michael Sims



More information about the talk mailing list