Hi all,

I have a question regarding the use of group by and order by in the same query.

I am trying to return a return a set of random results from a database, order by RAND(), but have them grouped together, by another field.

SELECT * FROM "db" WHERE town LIKE '$town' ORDER BY RAND()

Returns all the results in random order. I now want to group them with by another field.

SELECT * FROM "db" WHERE town LIKE '$town' GROUP BY sleeps ORDER BY RAND()

This works but obviously only returns 1 set of sleeps field, how do I return all entries?

http://www.choosespain.com/newtownpage.php is a basic order by RAND(), but as you'll see I need to Group the random results by the number of persons each property sleeps.

Hope I've explained myself ok.

Thanks in advance

Warren