所以基本上我试图做3个内部联接,这样我就可以获取适当的数据。以下是我的查询。我不太确定我哪里出错,看起来对我来说是正确的。
SELECT mdl_user.firstname,mdl_user.lastname,mdl_quiz_grades.grade
FROM mdl_user INNER JOIN mdl_quiz_grades ON
mdl_quiz_grades.userid = mdl_user.id
INNER JOIN mdl_quiz.id = mdl_quiz_grades.quiz
WHERE mdl_quiz_grades.timemodified >= UNIX_TIMESTAMP(LAST_DAY(CURDATE()) + INTERVAL 1 DAY - INTERVAL 1 MONTH)
AND mdl_quiz_grades.timemodified < UNIX_TIMESTAMP(LAST_DAY(CURDATE()) + INTERVAL 1 DAY)
ORDER BY mdl_quiz_grades.grade DESC
以下是错误
Static analysis:
2 errors were found during analysis.
An alias was previously found. (near "mdl_quiz_grades" at position 177)
An alias was previously found. (near "quiz" at position 193)
SQL query: Documentation
SELECT mdl_user.firstname,mdl_user.lastname,mdl_quiz_grades.grade FROM mdl_user INNER JOIN mdl_quiz_grades ON mdl_quiz_grades.userid = mdl_user.id INNER JOIN mdl_quiz.id = mdl_quiz_grades.quiz WHERE mdl_quiz_grades.timemodified >= UNIX_TIMESTAMP(LAST_DAY(CURDATE()) + INTERVAL 1 DAY - INTERVAL 1 MONTH) AND mdl_quiz_grades.timemodified < UNIX_TIMESTAMP(LAST_DAY(CURDATE()) + INTERVAL 1 DAY) ORDER BY mdl_quiz_grades.grade DESC LIMIT 0, 25
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.quiz
WHERE mdl_quiz_grades.timemodified >= UNIX_TIMESTAMP(LAST_DAY(CURDATE())' at line 4