Hi, recently I have posted this question and now I want the same query but with one relationship.
Now I have the "feeds" table and the "feed_entries" table. I want a limited amount of rows per category. The query above make use of one table with category_id field:
SELECT x.* FROM (SELECT t.*,
CASE WHEN @cat != t.category_id THEN @rownum := 1 ELSE @rownum := @rownum + 1 END AS rank,
@cat := t.category_id
FROM feed_entries t
JOIN (SELECT @rownum := NULL, @cat := 0) r
ORDER BY t.category_id DESC) x
WHERE x.rank <= 3 AND x.deleted =0 ORDER BY x.category_id, x.date DESC LIMIT 50
But instead of t.category_id I need to use f.category_id from the "feeds" table. How can I specify the relationship in this query?