I suggest to first analize the problem and then go through the query, php coding ...etc etc In the table u have only one superkey which is also a key and it is made of the three fields (attributes) 'category', 'language' and ' name'. You should consider to look for a prymary key randomly, toghether with some restriction in the search. Something like select the pryimary key from the table where 'category' equals a number(1, 2,3,....n) and 'name' equals some random criterium generated number. A random criteria could be generating a random variables between the ascii code representing the alphabet letters (from 97 to 122 to cover a,b,c,...z). You need to do some work before u can get an executable code here. Hope can open a road Bye "Torsten Roehr" <roehr@xxxxxxxxxxx> ha scritto nel messaggio news:20040629110054.63882.qmail@xxxxxxxxxxxxxxx > 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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php