I have this table:
id
feed_id
...
Let\'s say that I have 500 rows and I want to select 3 entries for each feed_id? And 50 as total limit.>
Use:
SELECT x.feedid
FROM (SELECT t.feedid,
CASE WHEN @feed != t.feedid THEN @rownum := 1 ELSE @rownum := @rownum + 1 END AS rank,
@feed := t.feedid
FROM TABLE t
JOIN (SELECT @rownum := NULL, @feed := 0) r
ORDER BY t.feedid) x
WHERE x.rank <= 3
ORDER BY x.feedid
LIMIT 50
What's not clear is the details of what you want returned - all the rows in your table, or just the feedid.