Saturday, 17 August 2013

MYSQL retrieving user activity where the same user_id can appear a maximum of 3 times

MYSQL retrieving user activity where the same user_id can appear a maximum
of 3 times

I'm retrieving rows from an user activity table like so
SELECT user_id, type, source_id FROM activity ORDER BY date DESC LIMIT 5
But I don't want the activity feed to be able to be clogged up by the same
user, so I want to be able to retrieve a maximum of 3 rows out of 5 that
contain the same user_id.
Any ideas how I could do this? Thanks :)

No comments:

Post a Comment