Re: Re: [sqlite] Selecting a random row from a table

2006-04-17 Thread 马国庆
Thomas Chust,您好! the mail num is so many, how can cancel the maillist. === 2006-04-16 16:03:00 您在来信中写道:=== >On Sun, 16 Apr 2006, [EMAIL PROTECTED] wrote: > >> Thomas Chust <[EMAIL PROTECTED]> wrote: >>> Hello, >>> >>> I have a table of strings and integer primary keys from

Re: [sqlite] Selecting a random row from a table

2006-04-16 Thread Thomas Chust
On Sun, 16 Apr 2006, [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] writes: [...] I cannot think of a more efficient way to do this if you require each output to have equal probability. If you do not need each string to have exactly the same probability, however, you could do this: SELECT

Re: [sqlite] Selecting a random row from a table

2006-04-16 Thread Thomas Chust
On Sun, 16 Apr 2006, [EMAIL PROTECTED] wrote: Thomas Chust <[EMAIL PROTECTED]> wrote: Hello, I have a table of strings and integer primary keys from which I would like to retrieve a string at random. [...] I cannot think of a more efficient way to do this if you require each output to have

Re: [sqlite] Selecting a random row from a table

2006-04-16 Thread drh
Thomas Chust <[EMAIL PROTECTED]> wrote: > Hello, > > I have a table of strings and integer primary keys from which I would like > to retrieve a string at random. The best solution I could think of was to > first do a > SELECT count(id) FROM strings; > and then a > SELECT string FROM

[sqlite] Selecting a random row from a table

2006-04-15 Thread Thomas Chust
Hello, I have a table of strings and integer primary keys from which I would like to retrieve a string at random. The best solution I could think of was to first do a SELECT count(id) FROM strings; and then a SELECT string FROM strings LIMIT 1 OFFSET ?; where the parameter is set to an