Hello, I have articles and images. Each article has many images.
The query below retrieves article id, article title and select via a join the image that goes in article.
Obviously I need only one article, but I need to get only one image per article. It is getting first image that it finds which has the article id tied to it.
How can I grab the last image, please?
"SELECT a.id as aid, a.title as title,i.imageid as image from articles as a
LEFT JOIN image as i on(a.id=i.id)
where a.visible='1'
GROUP BY a.id ORDER by a.id DESC, i.imageid DESC
LIMIT 10";