MySQL: Random select with specific count of a column
| From: | Torsten Roehr | Date: | Tue, 29 Jun 2004 11:00:23 +0000 |
| Subject: | MySQL: Random select with specific count of a column | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-35034@lists.php.net to get a copy of this message | ||
Hi,
I've got the following table:
category language name
1 de a
1 de b
1 de c
2 de a
2 de b
2 de c
3 de a
3 de b
3 de c
...
1 en a
1 en b
1 en c
I would like to select 6 random rows where the language is 'de' AND make
sure that I will always have 2 rows of EACH category in my result set:
1 de b
1 de c
2 de a
2 de c
3 de a
3 de b
Any help greatly appreciated.
Thanks and best regards,
Torsten Roehr