note 2031 deleted from mysql_query by danbeck
| From: | danbeck@php.net | Date: | Thu, 07 Sep 2000 17:17:18 +0000 |
| Subject: | note 2031 deleted from mysql_query by danbeck | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-4420@lists.php.net to get a copy of this message | ||
To select a random row from a table using MySQL:
<pre>mysql_quert("SELECT *, id*rand() AS rnd FROM table ORDER BY rnd LIMIT
1");</pre>
<pre>id</pre> should be the primary key. Use <pre>*</pre> if you want to
select all field from the row or you may specify each field individually in the query.