Re: Random selection
| From: | Jim Lucas | Date: | Sat, 23 Aug 2003 15:15:31 +0000 |
| Subject: | Re: Random selection | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-160506@lists.php.net to get a copy of this message | ||
Try this:
SELECT name FROM table GROUP BY name ORDER BY RAND() LIMIT 3
This will group together all the names and then choose from a list that has
only unique names and then return 3 at random.
Jim Lucas
----- Original Message -----
From: <fkeessen@planet.nl>
To: <php-general@lists.php.net>
Sent: Saturday, August 23, 2003 6:06 AM
Subject: [PHP] Random selection
> Hi,
>
> Can you help me with this one??
>
> In my mysql db i have a colum called names;
>
> In names their are:
>
> Frank
> Frank
> Bob
> Alice
> Bob
> Alice
> Jim
> Alice
> Frank
>
> I want to make a random selection (max 3 value's for example).. Only it
may not produce two times the same name. For example;
>
> This is the output:
>
> Frank, Jim, alice
>
> Wrong output
>
> Frank, Frank, Jim
>
> Please help!
>
> Thanks,
>
> Frank
>
>
>
----------------------------------------------------------------------------
----
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php