Sorry guys, but it's been a few months since I needed to do anything beyond basic SQL, and my brain's gone a bit foggy on it.
I have three tables. For a single query, I need to pull data from all three. Worst case scenario, I know how to get the results I want using 5 queries. But... *5 queries*? No.
The three tables are posts, threads, and users. 'posts' references 'threads' and 'users' by foreign keys. For this query, I need to summarize threads. So the data I need is:
name of the thread (contained in 'threads')
date started (contained in 'posts')
date last updated (contained in 'posts')
name of the user who started it (contained in 'users')
name of the user who updated later (contained in 'users')
Now, the horribly inefficient way of doing this is to query 'threads' first for the summary of titles, then for each result there query 'posts' for the start date, and then query 'users' for the username, then query 'posts' for the end date and 'users' again for the username that time. But that's a big mess.
So what's a better way to do things?
a series of linked queries
Moderator: General Moderators