The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How can i get the first post only?
somebody know the way to get only first post ,
ex: i have the topic with 20 reply on it. xxx (owner posted) x1 x2 x3 ... x20 now i want to write a query to get only xxx (owner posted) how can i do it Thank for reading my question |
#2
|
|||
|
|||
[SQL]
SELECT * FROM thread LEFT JOIN post ON ( post.postid = thread.firstpostid ) WHERE thread.threadid = AAA [/SQL] (Where AAA is the thread id) |
#3
|
|||
|
|||
thank Opserty
|
#4
|
||||
|
||||
You may want to just grab the post's info, instead of including thread data, to save on memory.
[sql]SELECT p.* FROM thread AS t LEFT JOIN post AS p ON (p.postid = t.firstpostid) WHERE t.threadid = X[/sql] |
#5
|
||||
|
||||
I hate it when people use single letters in sql.
|
#6
|
||||
|
||||
[sql]SELECT post.*
FROM thread AS thread LEFT JOIN post AS post ON (post.postid = thread.firstpostid) WHERE thread.threadid = X[/sql] Happy now, Paul? |
#7
|
|||
|
|||
You don't need the "AS thread" or "AS post" if they are the same as the table names no?
|
#8
|
|||
|
|||
even easier
PHP Code:
PHP Code:
|
#9
|
|||
|
|||
wow it's great for coder. big thank all
--------------- Added [DATE]1215142664[/DATE] at [TIME]1215142664[/TIME] --------------- thank for first question. now i got trouble with query my query: Code:
$x = $vbulletin->db->query_read(" SELECT * FROM " . TABLE_PREFIX . "thread as t INNER JOIN " . TABLE_PREFIX . "post as p ON (t.threadid = p.threadid) WHERE forumid IN(xx) ORDER BY p.post_thanks_amount DESC LIMIT 0 , 5"); while ($xxx = $vbulletin->db->fetch_array($x)) { $mymessage = $xxx['threadid']; $threaddm->do_set('pagetext', $mymessage); } the thread auto create perfectly with all infomation but 'pagetext' can not get anything from my query, it's empty. i want to ask who can help me: how can i get 5 threadid and put it on 'pagetext' it's mean 1 new thread with 5 threadid (i got from above query) on its best regard, |
#10
|
|||
|
|||
please help me with code
my query: Code:
$x = $vbulletin->db->query_read(" SELECT * FROM " . TABLE_PREFIX . "thread as t INNER JOIN " . TABLE_PREFIX . "post as p ON (t.threadid = p.threadid) WHERE forumid IN(xx) ORDER BY p.post_thanks_amount DESC LIMIT 0 , 5"); while ($xxx = $vbulletin->db->fetch_array($x)) { $mymessage = $xxx['threadid']; $threaddm->do_set('pagetext', $mymessage); } $threaddm->do_set('forumid', $to_forum_1); $threaddm->do_set('postuserid', $postuserid); $threaddm->do_set('userid', $postuserid); $threaddm->do_set('username', $postusername); $threaddm->do_set('title', $title); $threaddm->do_set('allowsmilie', $allowsmilie); $threaddm->do_set('visible', $visible); $tid = $threaddm->save(); i want to ask who can help me: how can i get 5 threadid and put it on 'pagetext' it's mean 1 new thread with 5 threadid (i got from above query) on its best regard, |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|