使用JOIN查询时出现问题

时间:2013-12-28 06:46:43

标签: mysql sql

SELECT MsThread.ID, MsThread.ThreadName, Count(MsThread.ThreadName) AS TotalPost, ThreadCategory

FROM ( MsThread LEFT JOIN MsPosts ON MsThread.ThreadName = MsPosts.ThreadName )

GROUP BY MsThread.ID, MsThread.ThreadName, MsThread.ThreadCategory;

我已经检查了之前提及括号的线程,以便加入访问工作,但我的问题仍然存在。

1 个答案:

答案 0 :(得分:0)

试试这个:

我认为FROM语句中的括号是搞乱的。

SELECT MsThread.ID, MsThread.ThreadName, Count(MsThread.ThreadName) AS TotalPost, ThreadCategory
FROM MsThread LEFT JOIN MsPosts ON MsThread.ThreadName = MsPosts.ThreadName
GROUP BY MsThread.ID, MsThread.ThreadName, MsThread.ThreadCategory;

或者这个。它可能正在寻找LEFT“OUTER”JOIN。

SELECT MsThread.ID, MsThread.ThreadName, Count(MsThread.ThreadName) AS TotalPost, ThreadCategory
FROM MsThread LEFT OUTER JOIN MsPosts ON MsThread.ThreadName = MsPosts.ThreadName
GROUP BY MsThread.ID, MsThread.ThreadName, MsThread.ThreadCategory;