I have 2 tables. 1. news table 2. category table.
in news table i have id, title, category id in category table i have id and category name.
in news table there are many news items where multiple news items for each category.
what i need was to select 2 record per each category from news table, also i need to join those two tables, so that i can get the name of the category from category table. i tried using below query
SELECT * FROM (
SELECT
news.id, news.fk_lookups_category, lookups_category.name, news.title, news.description,news.datetime,lookups_category.priority
FROM news
JOIN lookups_category ON news.fk_lookups_category=lookups_category.id
WHERE
news.isPublished='1' and news.datetime >= ('today' - INTERVAL 7 day) order by datetime DESC
) as newitem order by priority