![]() |
[SQLITE2] Complicated SELECT with 2 sub-queries
Hi everyone, it's been a long time but I'm getting back into the swing of things. Started my own company, so it has been hectic of late.
I'm struggling with a complicated sub-query that traces through 3 tables to get the last poster in a forum. Everything else works absolutely great. Please be patient with me, since my brain is rather scrambled with this cryptic logic. Here's the table structure: sql Code:
Okay, got that? Here's the query. I'll even mark the second subquery, because I've no clue how to write it now. sql Code:
What I'm TRYING to do is this: get the ID/NAME of the last poster from the database. Currently, the software is only looking at the "forum list" view, so I don't want to run 18 queries on this. So the query gets all the forums, and then subqueries for the thread count, and then the last poster. Again, the last is my trouble. So I'm kind of stuck. How should I rewrite this query? I organized my DB this way for simplicity, and because I'm still only novice/intermediate with MySQL/SQLite. And just for the record, I know that just about the last thing the world needs is yet another forum package, but I'm writing this to learn a few key concepts (that aren't SQL). |
Okay, I understand someone with inadequate knowledge of sub-selects leaving this topic untouched, but what about everyone else? SQLite supports 98% of MySQL's syntax.
I did manage to query within a forum for threads and their most recent poster. However, I'm still uncertain how to do this from the index without a per-forum query. Here's the forum-specific query. However, I suspect that it'll return a result for each post in the thread. *!* sql Code:
|
EDIT:::: nvm i misread your second post. ehhhh long day.
|
It happens. ;-)
Have any ideas about the first? I've got the second query working great now, but I haven't actually made progress on the second one. |
| All times are GMT. The time now is 12:53 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0