Forums :: Blogs :: Blog entry for 18 September 2005 01:06:19 GMT

18th September 2005 01:06:19 GMT
Blog entry for 18 September 2005 01:06:19 GMT
Rob
Rob's avatar

Seraphic/8X
85 post(s) since
24th November 2004 22:22:29 GMT
I've finally got the blogs database calls down to just one, and here is the SQL...

SELECT blogs.*, threads.id, COUNT(posts.id)-1
FROM blogs
    LEFT JOIN threads ON blogs.date = threads.date AND threads.title LIKE 'Blog Entry for %'
    LEFT JOIN posts ON threads.id = posts.threadId
GROUP BY blogs.date
ORDER BY blogs.date DESC
LIMIT $blogOffset, 10;

Before today, each blog entry had another SQL statement to determine the number of comments made, making eleven database calls in total.  Now there's just one.

I understand that joining a blog and forum together in this manner isn't terribly robust.  Using the date (accurate to only one second) and that the thread's title starts with "Blog Entry for", will have to do until I can come up with something better.
"Prepare for an oblivion for which there is no preparation." - O'Malley (Red Vs Blue)
28th September 2005 19:24:01 GMT
Blog Entry for 18 September 2005 01:06:19 GMT
tarquin
Archangel/1B
3 post(s) since
7th December 2004 10:23:13 GMT
Loser!

No - I love this site.  SO enriching.  Now - go to spleen.com.  It so good.  Write me a message beeathcthatch

Add Post

You must be Archangel/1B or greater to add posts to this thread.

Valid XHTML 1.1 Strict Valid CSS