我想知道另一个语法错误:
SELECT * FROM forum_question
WHERE category='art'
LEFT JOIN forum_answer ON (forum_question.id = forum_answer.question_id)
GROUP BY forum_question.id
ORDER BY a_datetime DESC;
我得到的错误是:
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 靠近'LEFT JOIN forum_answer ON(forum_question.id = forum_answer.question_id)第1行的B组
感谢。
答案 0 :(得分:2)
WHERE
子句应该在FROM
子句之后。 JOIN
语句是FROM
子句
SELECT *
FROM forum_question
LEFT JOIN forum_answer
ON (forum_question.id = forum_answer.question_id)
WHERE category='art'
GROUP BY forum_question.id
ORDER BY a_datetime DESC;
答案 1 :(得分:1)
WHERE
子句应位于JOIN
子句
SELECT *
FROM forum_question
LEFT JOIN forum_answer
ON (forum_question.id = forum_answer.question_id)
WHERE category='art'
GROUP BY forum_question.id
ORDER BY a_datetime DESC;
答案 2 :(得分:0)
首先join
,然后使用where
子句:
SELECT * FROM forum_question
LEFT JOIN forum_answer ON (forum_question.id = forum_answer.question_id)
WHERE forum_question.category='art'
GROUP BY forum_question.id
ORDER BY a_datetime DESC;