for 3)
if you have a set of random values e.g. 1,3, 6, 9, 4
then your sql will be
select * from your-table
where id in (1, 3, 6, 9, 4);

FYI:
if you are using ver 3.23.X, you may use 
SELECT * FROM your-table ORDER BY rand() LIMIT 5
contributed from: "Zak Greant" <[EMAIL PROTECTED]>

rand() seems using primary key of your table.

mine works in both old and new versions.


----- Original Message ----- 
From: "Webmaster" <[EMAIL PROTECTED]>
To: "Tony Shiu" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, May 09, 2001 12:27 PM
Subject: Re: SQL help


> i dont follow step #3.
> 
> 
> At 11:42 PM 5/8/2001, Tony Shiu wrote:
>  >i think it is more suitable to do it in programming level in mysql,
> though I
>  >know there is a function is M$sql server.
>  >
>  >if your table schema has a unique id field, before submit a query to
> DB,
>  >1) select count(*) from it
>  >2) from the above resultset, program to draw whatever number of
> records you
>  >want.
>  >3) submit the query, select * from it where id in (your random record
> ids);
>  >
>  >
>  >----- Original Message -----
>  >From: "Webmaster" <[EMAIL PROTECTED]>
>  >To: <[EMAIL PROTECTED]>
>  >Sent: Wednesday, May 09, 2001 11:38 AM
>  >Subject: SQL help
>  >
>  >
>  >> How do I write SQL in MySQL to randomly select 5 records from a
> table?
>  >>
>  >>
>  >>
> ---------------------------------------------------------------------
>  >> Before posting, please check:
>  >>    http://www.mysql.com/manual.php   (the manual)
>  >>    http://lists.mysql.com/           (the list archive)
>  >>
>  >> To request this thread, e-mail <[EMAIL PROTECTED]>
>  >> To unsubscribe, e-mail
>  >> <[EMAIL PROTECTED]>
>  >> Trouble unsubscribing? Try:
> http://lists.mysql.com/php/unsubscribe.php
>  >
>  >
>  >---------------------------------------------------------------------
>  >Before posting, please check:
>  >   http://www.mysql.com/manual.php   (the manual)
>  >   http://lists.mysql.com/           (the list archive)
>  >
>  >To request this thread, e-mail <[EMAIL PROTECTED]>
>  >To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
>  >Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to