这个SQL语法中的错误是什么?

时间:2013-04-15 02:39:26

标签: mysql sql join

我创建了这个SQL语句:

SELECT * 
    FROM forum_question 
        LEFT JOIN forum_answer ON (
            forum_question.id = forum_answer.question_id) 
    ORDER BY a_datetime DESC GROUP BY forum_question.id;

有谁知道这个问题? forum_question和forum_answer以及列'id'由by存在。

1 个答案:

答案 0 :(得分:4)

GROUP BY子句应该在ORDER BY子句之前出现。尝试交换它,

GROUP BY forum_question.id
ORDER BY a_datetime DESC