Okay, here's what I'm doing.. I am selecting a bunch of stuff from a database, from 3 tables. I need to select most of the fields from the
news table, and the
displayname and
id from the
authors table. I need to select the number of posts from the
post table (I used COUNT(*) WHERE postid=id before, but doesn't work with this because of the JOIN). Also, I need to get the
displayname (from the
authors table) of the corrisponding
edit_authorid (from
news table). I want to do this in as few queries as possible. I can get everything other then the posts count, and the edit info, because the edit info is dependant on the info being edited. I think I might have a workaround for that, by adding one extra query. But I can't think of a way to get the post's info figured out with out running a new query for each post, which will add 20 queries to the page load..
Here's what I have so far..
SELECT news.id, news.hits, news.forumID, news.timestamp, news.edit_timestamp, news.authorid, news.edit_authorid, news.subject, news.body, auth.id AS authorid, auth.displayname FROM pchm_news AS news, pchm_authors AS auth WHERE news.active='1' ORDER BY news.id DESC LIMIT 0, 20
I have been thinking about using a array to store all exatra data in, which would only add 2 more queries, which won't slow down the Quad 2GHz XEON server down much/any
I'll post anything else I get, but I really need some help ASAP