NYCPHP Meetup

NYPHP.org

[nycphp-talk] Need help randomly accessing records from adatabase

Cliff Hirsch cliff at pinestream.com
Thu Sep 1 09:41:57 EDT 2005


Awesome! I knew there had to be something out there!

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On Behalf Of Michael Sims
Sent: Thursday, September 01, 2005 9:38 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] Need help randomly accessing records from
adatabase


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
_______________________________________________
New York PHP Talk Mailing List
AMP Technology
Supporting Apache, MySQL and PHP
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org




More information about the talk mailing list