Re: How to find random records in a subset?
| From: | Marek Kilimajer | Date: | Fri, 03 Jun 2005 13:48:58 +0000 |
| Subject: | Re: How to find random records in a subset? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-216313@lists.php.net to get a copy of this message | ||
Brian Dunning wrote:
I am using a routine to find 50 random records in a large MySQL database (about a million records) where I generate a list of 50 random unique ID's,why can't you use the where condition in the above query?
and then use MySQL's "in" command to find them. I can't use "order by rand()" due to its performance hit. But I have to take it one more step: I want to first limit my found set to those matching a different search criteria, and then find 50 of those. Anyone? Can this be done all within MySQL, or is it going to require some humongo PHP arrays?