note 15667 modified in ref.mysql by tomsommer
| From: | tomsommer@php.net | Date: | Tue, 06 Jul 2004 09:27:08 +0000 |
| Subject: | note 15667 modified in ref.mysql by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72736@lists.php.net to get a copy of this message | ||
Hi, here's a nice little trick to select records in random order from a table in a MySQL
database prior to version 3.23
SELECT *, (ItemID/ItemID)*RAND() AS MyRandom FROM Items ORDER BY MyRandom
[Editors note: And just "SELECT * FROM foo ORDER BY RAND()" after 3.23]
--was--
Hi, here's a nice little trick to select records in random order from a table in a MySQL
database prior to version 3.23
SELECT *, (ItemID/ItemID)*RAND() AS MyRandom FROM Items ORDER BY MyRandom
[[[Editors note:
And just SELECT * FROM foo WHERE bar = RAND() after 3.23
]]]
http://php.net/manual/en/ref.mysql.php