The Doctor
Tue 8th Mar '05, 5:07pm
This is the most complex SQL query I've ever done, and so I don't khow whether I've just made a silly error or I've got a more fundamental misunderstanding.
Either way, I've been staring at it for too long and I need a new eye on the problem.
The query:
SELECT post.title, thread.title AS threadtitle, post.username, post.dateline, post.pagetext, post.threadid, thread.threadid, thread.forumid, deletionlog.primaryid, moderation.postid
FROM post
JOIN thread ON ( post.threadid = thread.threadid )
LEFT JOIN moderation ON ( post.postid = moderation.postid )
LEFT JOIN deletionlog ON ( (
post.postid = deletionlog.primaryid
AND deletionlog.type = 'post'
)
OR (
post.threadid = deletionlog.primaryid
AND deletionlog.type = 'thread'
) )
WHERE (
thread.forumid
IN ( 3, 4, 5, 6, 7, 8, 1, 2, 10, 11, 12, 13, 14, 15, 16 )
AND deletionlog.primaryid IS NULL
AND moderation.postid IS NULL
)
ORDER BY posts.postid DESC
LIMIT 10
and the error I get:
#1064 - You have an error in your SQL syntax near 'ON (post.threadid = thread.threadid)
LEFT JOIN moderation
' at line 8
Anyone got any ideas?
Either way, I've been staring at it for too long and I need a new eye on the problem.
The query:
SELECT post.title, thread.title AS threadtitle, post.username, post.dateline, post.pagetext, post.threadid, thread.threadid, thread.forumid, deletionlog.primaryid, moderation.postid
FROM post
JOIN thread ON ( post.threadid = thread.threadid )
LEFT JOIN moderation ON ( post.postid = moderation.postid )
LEFT JOIN deletionlog ON ( (
post.postid = deletionlog.primaryid
AND deletionlog.type = 'post'
)
OR (
post.threadid = deletionlog.primaryid
AND deletionlog.type = 'thread'
) )
WHERE (
thread.forumid
IN ( 3, 4, 5, 6, 7, 8, 1, 2, 10, 11, 12, 13, 14, 15, 16 )
AND deletionlog.primaryid IS NULL
AND moderation.postid IS NULL
)
ORDER BY posts.postid DESC
LIMIT 10
and the error I get:
#1064 - You have an error in your SQL syntax near 'ON (post.threadid = thread.threadid)
LEFT JOIN moderation
' at line 8
Anyone got any ideas?