![]() |
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. |
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. |
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 |
Now which one would be the least server-intensive? I vaguely remember Chen saying something about never joining the post and thread tables...
|
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...
|
@filburt: i'd use Codenames version, i think it's faster here.
Joining is needed for other issues. |
Okay, will try :)
|
Never use SELECT * unless you need it. Of course, there is an exception - if you lack common sense it won't matter ;).
|
All times are GMT. The time now is 09:20 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|