[Gllug] Perl DBI question

Adrian McMenamin adrian at newgolddream.dyndns.info
Tue Oct 3 13:48:09 UTC 2006


On Tue, October 3, 2006 2:28 pm, Russell Howe wrote:

> Also, note that RANDOM() sometimes isn't all that random depending on
> your RDBMS. I'd check the coverage of results for your particular
> application.
>
I tried SELECT item1, item2 ORDER BY RAND() LIMIT 1 which seems to work
well on Firefox on linux (there are only three items in the database at
the moment so that's not much to base this on!)

Interestingly, though, when I try this on IE6 it always comes up with the
same record - this is all done through a XMLHttpRequest object and so I
wonder if there is some sort of cache-ing going on. Does anyone know?

Now, I want to do this.

If the random event gives me item N, the next one I want is item N + 1
(however as N is the index N + 1 means the next item not necessarily the
arthmetic sum) unless N + 1 > EOF in which case I want the first item.

I do I do this? Order by the index (ie WHERE (index = N) ORDER By index)
and then get the next item? Or is there a more elegant way?



-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list