I have the following tables:
Table: news
fields: uid, title, categories, datetime, hidden, deleted
Table: categories_mn
fields: uid_local, uid_foreign
Table: categories
Fields: uid, parentcategory, name, image
Every news entry can be assigned to several different categories.
What Im trying to achieve is to get the latest 3 news, and show the image of all the categories that this entry is assigned to (and have a Image assigned)
Something like this:
title | catimages |
------------------------------
Post 7 | cat1.jpg |
Post 6 | |
Post 5 | cat1.jpg,cat3.jpg |
------------------------------
This is all I have so far:
SELECT title, categories
FROM news
WHERE deleted = 0 AND hidden = 0 AND
ORDER BY datetime DESC
LIMIT 3;
Im not very experienced with SQL. Please help.