你想要做什么对我来说并不完全清楚,但要使你的查询工作,你需要在 周围加上单引号$_SESSION['MM_Username']
,就像 gogowitsch 已经说过的那样。
还缺少另一个关闭括号。所以你的查询应该是这样的:
$query_Student = "SELECT Project_Title, Project_Lecturer FROM projects WHERE Project_id =
(SELECT Proj_id FROM project_course WHERE Cour_id = (SELECT Course_id from courses WHERE
Code = (SELECT Course FROM users WHERE Username = '".$_SESSION['MM_Username']."')))"
但...
这不是一个写得很好的查询。
我现在只是在猜测,但也许这就是你要找的:
SELECT
p.Project_Title,
p.Project_Lecturer
FROM projects p
INNER JOIN project_course pc ON p.Project_id = pc.Proj_id
INNER JOIN courses c ON pc.Cour_id = c.Course_id
INNER JOIN users u ON c.Code = u.Course
WHERE u.Username = 'yourUserName';
If not, show us the tables you are using (do a SHOW CREATE TABLE projects;
and so on for every table you are using and post it here) and maybe what output you expect, then we can really help.