hi,
Simple version:
I have a news table which has id and title.
I have a photos table which has id, id_news and importance.
News entries may or may not have photos.
News entries may have more than one photo.
How do I get all the news entries with along with the photo with highest importance?
I have tried
SELECT `news`.`id` AS id, `title`, `photo`
FROM (`news`)
LEFT JOIN `photos` ON `news`.`id` = `photos`.`id_news`
GROUP BY `news`.`id`
ORDER BY `date` DESC, `importance` DESC
but I can't seem to get the correct photo, the one with the highest importance.