Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
Crashin
Forum Contributor
Posts: 223 Joined: Mon May 06, 2002 3:42 pm
Location: Colorado
Post
by Crashin » Thu Sep 12, 2002 9:52 am
Hey all...
I'd like to construct a query that will pull a random record from my DB (MySQL) for display on our homepage. Is there a quick and dirty way to do this?
kcomer
Forum Contributor
Posts: 108 Joined: Tue Aug 27, 2002 8:50 am
Post
by kcomer » Thu Sep 12, 2002 10:08 am
Code: Select all
SELECT * FROM table_name ORDER BY RAND() limit 1;
Should work. Got it from the MySQL website. Imagine that.
Keith
Crashin
Forum Contributor
Posts: 223 Joined: Mon May 06, 2002 3:42 pm
Location: Colorado
Post
by Crashin » Thu Sep 12, 2002 10:17 am
Aw, shucks! MySQL has their own website??? Why, I never!
Thanks, man! I'll do better research next time...
kcomer
Forum Contributor
Posts: 108 Joined: Tue Aug 27, 2002 8:50 am
Post
by kcomer » Thu Sep 12, 2002 12:15 pm
Just giving you a hard time. Mine will come sometime I'm sure.