I'm trying to do a query to filter on rows from one table and then join the results on another table and then filter out additional rows.
Here is the query I've written:
SELECT *
FROM (SELECT media.id AS id2, media.flagged AS flagged2, media.item_status AS status2
FROM media
WHERE flagged2 != 'nsfw'
AND status2 != 'deleted'
ORDER BY id2 DESC LIMIT 0,5)
JOIN media on info.mid = media.id
WHERE info.topic = 'food_drink'
OR info.topic='cooking'
GROUP BY info.mid
I think I'm pretty close to getting the query working but I keep getting the message, "Every derived table must have its own alias." I've Googled this and from what I've read I need to alias parts of the subquery which I've tried but I still can't get it working.