
Originally Posted by
runrunforest
I only need one row, the row where thumb_name = 1259730015_thumb.jpg
why that one?
okay, let's go with the lowest thumb name per id...
Code:
SELECT news.id
, news.news_title
, news.published_date
, news_image.thumb_name
, news_image.image_name
FROM news
LEFT OUTER
JOIN ( SELECT id
, MIN(thumb_name) AS this_one
FROM news_image
GROUP
BY id ) AS mmmm
ON mmmm.id = news.id
LEFT OUTER
JOIN news_image
ON news_image.id = news.id
AND news_image.thumb_name = mmmm.this_one
WHERE news.news_type= 1
AND news.region = 2
ORDER
BY news.id DESC LIMIT 4
Bookmarks