Jay, If you're going to offer advice, at least do some basic research to
make sure it's accurate.

Firstly, having a column that has a random number in it and sorting by
it produces the same output each time you query on it - obviously
unsatisfactory and I would have thought, manor from heaven for card
counters everywhere!!

Secondly, the standard SQLite function random() is actually seeded by
the current time and date every time you open a database.

Steve

p.s. Sorry, been down the pub.....



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
rg] On Behalf Of Jay Sprenkle
Sent: 17 January 2006 14:09
To: sqlite-users@sqlite.org; Clark Christensen
Subject: [RBL] Re: [sqlite] Randomly ordering results

On 1/16/06, Clark Christensen <[EMAIL PROTECTED]> wrote:
>
> So, I have to ask, is this the right way to implement such
functionality?  Is there a better, or more efficient way?

The standard method of ordering a list randomly that doesn't return
duplicates
is to add a column for each of the items. Assign a random number to the
column.
The return the list sorted by the random number. It's used extensively
for shuffling
cards, etc.  You should be aware that the standard random number
functions
of most languages return the same sequence of results for the same
'seed' value.
So you generally have to do something like set the seed using the
current clock
so you get a different set of random numbers for each run of your
program.


Reply via email to