|
query combining newest threads and posts
|
|
04-11-2009, 10:37 PM
(This post was last modified: 04-11-2009 10:41 PM by irkenInvader.)
Post: #1
|
|||
|
|||
|
query combining newest threads and posts
I hope this hasen't been answered before, but here goes:
I'm trying to modify the Overview mod. Specifically, I want the latest threads box to show the threads which have the newest posts in them. In other words, I want to see a list of all the threads which have the latest posts in them. Here is the latest threads query being used in the Overview mod: PHP Code: $query3 = $db->query ("SELECT subject,username,uid,tid,views,replies FROM ".TABLE_PREFIX."threadsAnd here is the latest posts query used in the Overview mod: PHP Code: $query6 = $db->query ("SELECT subject,username,uid,pid,tid FROM ".TABLE_PREFIX."posts WHERE visible='1' ".get_unviewable()."My SQL-foo is weak, but I imagine I need some kind of join between those two tables to get what I want. Something that will let me capture 'subject', 'username',' 'uid', 'tid', 'views', and[/php] 'replies' from those posts that are newest. Can anyone give me a hand with this? |
|||
|
04-11-2009, 10:46 PM
Post: #2
|
|||
|
|||
|
RE: query combining newest threads and posts
in that latest thread query; change dateline into lastpost
MyPluginsFor1.4 |
|||
|
04-11-2009, 11:18 PM
Post: #3
|
|||
|
|||
|
RE: query combining newest threads and posts
I have accomplished what I was looking for ...
PHP Code: $query3 = $db->query ("SELECT p.tid,t.subject,t.username,t.uid,t.views,t.repliesThe above is the modified query I use to get the info I'm looking for, just in case any one else is looking for this. |
|||
|
04-12-2009, 03:07 AM
Post: #4
|
|||
|
|||
|
RE: query combining newest threads and posts
As Lex said, you should be able to just query the threads with order by lastpost, instead of such an expensive join operation.
Google SEO | Gravatar | Hooks | HTMLPurifier | Overview | Patches | PluginLibrary |
|||
|
04-12-2009, 03:36 PM
(This post was last modified: 04-12-2009 03:37 PM by irkenInvader.)
Post: #5
|
|||
|
|||
|
RE: query combining newest threads and posts
Thank you, LeX- and frostschutz.
I've changed my query back to the original and modified the ORDER BY section, as suggested by you, to use the lastpost field instead of JOINing the two tables. However, I have come to realize I really want the last posts username in my output, not the thread's username. Is there an easy way to get that without another query? edit -- hehe ... silly me. I'm guessing that's exactly what the latestposter field is for? Thanks again for your helps. |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)
Search
Member List
Calendar
Help




