Joining multiple tables!

wxdqz

New Member
I'm currently trying to integrate a Perl/SQL news script with vBulletin. So far so good... I can get it to create a new thread for each post, update the news script's SQL table to contain the "threadid" ( which is by default set to '0' )and everything.

Now, here's where I run into problems... some of the posts were made a while ago and do not have a thread associated with them ( this is not a bug or anything ).

I join the two tables using the following code...

$db1 = "NewsDB.newstable";
$db2 = "vBulletinDB.thread";

SELECT * FROM $db1, $db2 WHERE ($db1.threadid = $db2.threadid) OR ($db1.threadid <= 0) ORDER BY newstime DESC

This works fine when the post has an associated thread, but posts that don't have a thread associated are repeated multiple times...

For a example, take a look @ <!-- m --><a class="postlink" href="http://csql.sardonica.net/cgi-bin/coranto_sql/all.html">http://csql.sardonica.net/cgi-bin/coranto_sql/all.html</a><!-- m -->

btw, "newstime" is just the unix timestamp.
 
Back
Top