The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
MyChenQL, part 5
How can I make this into valid SQL for MySQL (i.e., dump the nested query):
[sql] SELECT pagetext FROM post WHERE threadid = (SELECT threadid FROM thread WHERE forumid = 18 ORDER BY dateline DESC LIMIT 1) ORDER BY dateline ASC LIMIT 1 [/sql] English: select the pagetext from the first post in the most recent thread in forum 18. |
#2
|
|||
|
|||
SELECT post.pagetext, thread.dateline, thread.forumid FROM post, thread WHERE thread.forumid=18 && post.threadid=thread.threadid ORDER BY thread.dateline ASC LIMIT 1;
Try that. |
#3
|
||||
|
||||
SELECT post.*, thread.* FROM post LEFT JOIN thread ON post.threadid=thread.threadid WHERE thread.forumid=18 ORDER BY thread.dateline ASC LIMIT 1;
Satan |
#4
|
|||
|
|||
Now which one would be the least server-intensive? I vaguely remember Chen saying something about never joining the post and thread tables...
|
#5
|
|||
|
|||
xD you could always use the Union (i just learnt it an hour ago) it joins multiple queries to one and really increases load time...
|
#6
|
||||
|
||||
@filburt: i'd use Codenames version, i think it's faster here.
Joining is needed for other issues. |
#7
|
|||
|
|||
Okay, will try
|
#8
|
|||
|
|||
Never use SELECT * unless you need it. Of course, there is an exception - if you lack common sense it won't matter .
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|