如何优化此查询?如果您需要表结构,请告诉我,但这是作为Vanilla论坛的自定义插件
完成的SELECT
G.*
FROM
(
SELECT
D.DiscussionID,
A. NAME AS Category,
D. NAME,
U. NAME AS USER,
D.CountComments,
IFNULL(
MAX(C.DateInserted),
D.DateInserted
) AS Updated
FROM
GDN_Discussion AS D
LEFT OUTER JOIN GDN_Comment AS C ON D.DiscussionID = C.DiscussionID
INNER JOIN GDN_Category AS A ON A.CategoryID = D.CategoryID
LEFT OUTER JOIN GDN_User AS U ON U.UserID = D.InsertUserID
WHERE
A.CategoryID = '626'
GROUP BY
D.DiscussionID
) AS G
ORDER BY
G.Updated DESC
LIMIT 0, 10