I want to get every ‘Forum_THREADS’ a user posted to, or replied to.
When they reply, it’s in the ‘Forum_REPLIES’ table.
Here’s my query:
$threads = mysql_query("SELECT * FROM FORUM_Threads
INNER JOIN FORUM_Replies
ON
FORUM_Threads.Poster = $userRow->ID
OR
(
FORUM_Replies.Poster = $userRow->ID
AND
FORUM_Replies.ThreadID = FORUM_Threads.ID
)
");
At the moment it’s not working properly, and when it does, I’d imagine it’d fetch some threads multiple times. Is there any better way to do this where it won’t fetch threads multiple times, and it’ll work properly?
Forum_REPLIES is just a duplicate of Forum_THREADS with the ‘ThreadID’ field.
It’s not working because you must join on a column in
FORUM_Replies, not a scalar value ($userRow->ID).It looks like you’re using a JOIN where you really should be using a WHERE clause.