这个MySQL查询有什么问题? INNER_JOIN WHERE子句的正确语法?

时间:2014-04-14 16:31:05

标签: mysql sql phpmyadmin

SELECT core_student.STUDENT_ID, core_student.FIRST_NAME, core_student.LAST_NAME
FROM `core_student`
INNER_JOIN `ssp_student`
WHERE ssp_student.STUDENT_ID = core_student.STUDENT_ID;

WHERE子句上抛出错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to user near 'ssp_student' WHERE ssp_student.STUDENT_ID = core_student.STUDENT_ID

我只想选择SELECT中列出的字段,然后加入ssp_studentssp_student.STUDENT_ID字段与core_student.STUDENT_ID字段相同的所有列。< / p>

1 个答案:

答案 0 :(得分:1)

正确的方法是

SELECT core_student.STUDENT_ID, core_student.FIRST_NAME, core_student.LAST_NAME
FROM `core_student`
INNER JOIN `ssp_student`
on ssp_student.STUDENT_ID = core_student.STUDENT_ID;