List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:July 29 1999 11:16am
Subject:Re: random research
View as plain text  
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;

Regards,
  Martin
-- 
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
Thread
random researchTommaso Melodia29 Jul
  • Re: random researchMartin Ramsch29 Jul
    • Re: random researchPaul DuBois29 Jul