Question : Sql query to get latest blog post from each blogger

Hi,

I've made a blog module and need a sql query where I can get the latest blog post for each blogger. My tables looks like this:

contentBlogs
blogID, bloggerName

contentBlogPosts
blogPostID, publishedDate, blogText, blogTitle, blogID

Thanks for your help!

Peter

Answer : Sql query to get latest blog post from each blogger

Assuming it is publishedDate and they are unique than something like this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
SELECT	b.bloggerName,
	p.publishedDate, 
	p.blogText, 
	p.blogTitle
FROM	contentBlogs b
	INNER JOIN contentBlogPosts p ON b.blogID = p.blogID
	INNER JOIN (
		SELECT	blogID,
			MAX(publishedDate) LastpublishedDate
		FROM	contentBlogPosts
		GROUP BY
			blogID) p2 ON b.blogID = p2.blogID AND p.publishedDate = p2.LastpublishedDate
Random Solutions  
 
programming4us programming4us