If you want to guarantee that the selections are different, rand()
doesn't quite do it, as you will get a repeated value with the
appropriate probability.  You will need to keep a record of
what values have already been seen.  Then, use something
like
  select ...
  from my_table left join my_records_used using (my_id)
  where my_records_used.my_id is null
  order by rand()
  limit 1

> Date: Tue, 20 Apr 2004 13:08:01 -0700 (PDT)
> Subject: Re: Randomly selecting from table
> From: "Daniel Clark" <[EMAIL PROTECTED]>
> To: "Eve Atley" <[EMAIL PROTECTED]>

> Guess you could use the rand() function and look for a matching row id!?!

> > Is it possible to randomly select from all entries in a table, but have
it
> > be 2 different ones each time? If so, what documentation should I be
> > looking
> > at?
> >
> > I am using PHP and MySQL together, if this helps.
> >
> > Thanks,
> > Eve


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to