On Sat, 1999-09-18 02:57:53 +0300, Michael Widenius wrote:
> >> Is it possible to SELECT a random recordset out of a database?
> Another option is to do the following:
> SELECT *,rand() as r from table ORDER BY r LIMIT 5
> In this case you must just ignore the last column in your application.
For MySQL V3.22.19b (that's what I'm still using here) this doesn't
work! One always gets the same five rows in the same order, though
column r shows different random numbers each time ...
I could get it to work by adding a table field to the rand() term:
SELECT *, id*0+RAND() AS r FROM table ORDER BY r LIMIT 5;
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26 E4 EC 80 58 7B 31 3A D7