Joining Tables In SQL
I am having trouble with a SQL query. SELECT t.topicname, m. *, ms.avatar FROM `messages` m INNER JOIN topics t ON m.topicid = t.topicid inner join users u on m.author=u
Solution 1:
Seems you don't have users and avatars filled for each message.
Try replacing the INNER JOINS with the OUTER JOINS.
SELECT t.topicname, m. *, ms.avatar
FROM `messages` m
JOIN topics t
ON t.topicid = m.topicid
LEFT JOIN
users u
ON u.username = m.author
LEFT JOIN
misc ms
ON ms.userid = u.userid
ORDER BY
m.postdate DESC
LIMIT 5
Post a Comment for "Joining Tables In SQL"