views:

38

answers:

0

I have a query (source)...

UPDATE covers t
LEFT OUTER JOIN 
    (SELECT cover_id FROM covers ORDER BY cover_views DESC LIMIT 10) c 
    ON c.cover_id = t.cover_id
SET cover_views = 0
WHERE c.cover_id IS NULL

...which resets all but the top 10 covers in the database to 0. I want to extend this to reset all covers bar the top ten per cover_catid. Essentially keep the top ten in each category. How can I do this without doing multiple queries or is that the best option?

Thanks