Re: using rand()
| From: | Ryan A | Date: | Fri, 08 Apr 2005 02:14:08 +0000 |
| Subject: | Re: using rand() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-212611@lists.php.net to get a copy of this message | ||
> why not do two select statements using the ORDER BY RAND() then append:
>
> LIMIT 3 for your women,
>
> and then
>
> LIMIT 1 for your men
>
>
>
> so the first one is:
>
> $result1 =
> mysql_query("select * from {table} where sex='female' order
> by rand() limit 3;");
>
> the second:
>
> $result2 =
> mysql_query("select * from {table} where sex='male' order
> by rand() limit 1;");
>
>
>
> where {table} is the name of your table...
>
>
>
> drew
Thanks Drew,
Simple solution to a simple problem.....guess I'm sitting on my brains right
now...or am just braindead.
Time for a break and guitar playing :-)
Cheers,
Ryan
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.4 - Release Date: 4/6/2005