PDA

View Full Version : LEFT JOIN help


assassingod
09-16-2003, 02:48 PM
I need to grab info from 1 column from a different table from the one im selecting. I'm assuming its a left join but i may be wrong


$news = $DB_site->query("
SELECT thread.threadid,thread.title,thread.replycount,thr ead.postusername,thread.postuserid,thread.dateline ,thread.views,thread.iconid
FROM thread
WHERE forumid = '5'
ORDER BY thread.dateline DESC
LIMIT 3
");


I tried using 'LEFT JOIN post ON post.pagetext=thread.pagetext' then selecting thread.pagetext in the SELECT bit, but didn't work.

Anyone help me?

(BTW, I do have my while loop code, I just didn't include it there)

I still haven't understood LEFT JOIN's properly:(

Xenon
09-16-2003, 04:52 PM
try LEFT JOIN post ON (post.threadid = thread.threadid AND post.dateline = thread.dateline)

then use post.pagetext in select ;)

assassingod
09-16-2003, 05:23 PM
I'll test it, thanks much!

assassingod
09-16-2003, 07:25 PM
Edit:
Got it working, much appreciated Xenon

Xenon
09-16-2003, 09:42 PM
you're welcome :)