List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:July 29 1999 11:39am
Subject:Re: random research
View as plain text  
At 6:16 AM -0500 7/29/99, Martin Ramsch wrote:
>On Do, 1999-07-29 02:18:28 +0200, Tommaso Melodia wrote:
>> Could anybody explain me quickly how do I perform a random research on a
>> series of records using mysql?
>
>The maybe most simple way is to first look up how many records are
>there:
>  SELECT COUNT(*) AS n FROM ... WHERE ...;
>
>Retrieve this n, compute a random number between 1 and n, say x,
>and then do:
>  SELECT ... FROM ... WHERE .... LIMIT x,1;


Just a small correction: x would be between 0 and n-1.
The record numbering for the two-argument form of LIMIT
begins at 0, not 1.

--
Paul DuBois, paul@stripped
Thread
random researchTommaso Melodia29 Jul
  • Re: random researchMartin Ramsch29 Jul
    • Re: random researchPaul DuBois29 Jul