http://www.mysql.com/doc/M/a/Mathematical_functions.html

describes how to do this using the RAND() function.



-----Original Message-----
From: Alec Smith [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 18, 2001 6:27 PM
To: [EMAIL PROTECTED]
Subject: How to structure a random query


I'm just starting to learn SQL and MySQL, and am curious as to how the
following query might be built.

I've got a table of X rows, each with a unique ID as determined by
auto_increment when the row is inserted into the database. How would I go
about doing a SELECT on a row of the database and have MySQL return a row
at random?

I figure there must be an easier way then doing a SELECT count(*) from
tablename, using that in a random generator in Perl/PHP, and then looking
up the resulting row with a second MySQL query.

Thanks,
Alec


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to