I am trying to write a single query that does the following:
- reads all threads where forumid = $forumid
- reads all posts where threads.firstpostid = postid
- reads all polls where threads.pollid = pollid, but only if a poll exists
I tried:
PHP Code:
SELECT thread.*, post.*, IF(thread.pollid = poll.pollid, poll.*, '')
FROM " . TABLE_PREFIX . "thread, " . TABLE_PREFIX . "post, " . TABLE_PREFIX . "poll"
WHERE thread.forumid = '" . $forumid . "'
AND post.postid = thread.firstpostid
AND IF(thread.pollid = poll.pollid, poll.pollid = thread.pollid, '1 > 0')
ORDER BY dateline DESC
but it just gives T_STRING errors and returns NULL...