i have a db with records with date (timestamp) i need to select 10 records for each day (there are many more per day) and order them by few columns...
how should that qu
You have to get your 10 records per day in a subquery for each day and join them to the main table by a left join, so you'll get max 10 records per day. The SQL would look like this:
SELECT t1.columns
FROM mytable t1
LEFT JOIN
(SELECT pk FROM mytable t2
WHERE t2.datecol = t1.datecol
ORDER BY t2.orderFor10Rows LIMIT 10) t3
ON t1.pk = t3.pk
ORDER BY t1.anyOtherColumns
No warranty for proper MySQL-syntax as I'm not used to it.