Re: MySQL: Random select with specific count of a column
| From: | Pablo M. Rivas | Date: | Tue, 29 Jun 2004 14:00:44 +0000 |
| Subject: | Re: MySQL: Random select with specific count of a column | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-35037@lists.php.net to get a copy of this message | ||
Hello Torsten,
This is one, but I think you can find another one:
Supose your table is called tablename
select * from tablename as a left join tablename as b on
a.category = b.category and a.name<>b.name and
a.language=b.language where a.language='de' and b.name is not
null group by a.category
....
TR> I would like to select 6 random rows where the language is 'de' AND make
TR> sure that I will always have 2 rows of EACH category in my result set:
....
--
Best regards,
Pablo