How to query 10 random unique records in mysql database?
mysql
Solution
select DISTINCT(category),id,image_name FROM images
WHERE id=
(FLOOR(RAND() *
(SELECT COUNT(*) FROM images )
)
);
Problem
Possible Duplicate: how to select random unique records on each execution of the SQL Query I have database of that structure: ``` id int image_name varchar(200) category_id int ``` There are about 200 records, id is unique, and there are about 20 categories, and my iamges are categorized between them. Could you help me to get a query, which will give me 10 records with UNIQUE category_ids?