The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#11
|
||||
|
||||
Quote:
Now in your case, we can assume you have more than two posts to the thread with the id 140. Since the DISTINCT eliminates all but the last one, the oldest post is kept, not the newest, and 140 drops out of your top 15. So, this gets a little tricky. I have to go do some stuff, but I'll work out the query for you and post it later tonight (early tomorrow). There may be a way to do this with just SQL, but, I can't come up with it at the moment. You're going to need to process the results. Since you're dealing with all of a users threads this could be a large query result to step through. Depending on your specific performance issues it might be more efficient to keep a separate table with userid and threadid that you update when a users posts. It would only keep the latest 5. You could also timestamp it and actually show the correct order if a user posts in a thread twice. For example, I post in threadid 210, then I post in two other threads, then I post in 210 again. I wouldn't put 210 into the table twice, but I would update 210's timestamp. Otherwise, you could just read in the entire result set (all their postid, threadids) and then loop through it until you have 15 unique threadids... |
#12
|
||||
|
||||
Hey Thanks for the Help guys,
Cap'n Steve I tried your query. I started by posting in a really old thread. With the old query that actually shows the last posts (including duplicates) I got: SELECT threadid FROM post WHERE userid = 1 ORDER BY postid DESC LIMIT 15 140 1434 1332 1434 1445 1412 1434 1412 1412 1406 1091 1305 1368 1408 1378 These are the actual threadids of the last 15 posts I made, and in order, I checked. When I added the GROUP BY threadid to the query (and changed the number to 5), it gave me 1445 1434 1406 1305 1368 Now it really makes no sense lol... |
#13
|
||||
|
||||
You need to order it by dateline, postid. That's why is not working.
|
#14
|
||||
|
||||
That's not going to help.
|
#15
|
||||
|
||||
[sql]SELECT threadid
FROM thread WHERE postusername = 'John' AND dateline > (UNIX_TIMESTAMP(NOW()) - 172800) AND visible = 1 ORDER BY lastpostid, threadid DESC LIMIT 15;[/sql] That will return the threads for the last 48 hours, less scanning to the tables. I did this off my head, so play with the ORDER there, if it's not right. EDIT: you should definitelly consider forum based perms for your query, orelse anyone could see private threads on public areas. |
#16
|
||||
|
||||
That query gets the latest threads made by the user, I want the latest threads the user posted in.
|
#17
|
||||
|
||||
[sql]SELECT DISTINCT(post.threadid), thread.title FROM post, thread WHERE post.userid=1 AND thread.visible=1 AND thread.threadid=post.threadid ORDER BY post.dateline DESC LIMIT 5[/sql]
returned the following for me: Code:
threadid thread.title 5333 Holy vs. Suija (Omega Arc vs. Sakura) 5332 Hatsuharu vs. Black Rose (Sasuke vs. Sakura) 5270 Xepher Bladewing vs. Black Rose (Xepher Bladewing ... 5255 Xepher Bladewing vs. Black Rose (Xepher Bladewing ... 5186 RPG Palace:: THE GAME! |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|