I need to filter data based on one table, but i dont know the correct usage for the select from function in php mysql. The below code shows what i am trying to do, but I think you can use multiple SELECT.
$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']."))"
Can anyone offer any assistance to what I need to write instead?
What you want to do is not exactly clear to me, but to make your query work you need to put single quotes around
$_SESSION['MM_Username'], like gogowitsch already said.Also another closing paranthese is missing. So your query should look like this:
But…
That is not a very well written query.
I’m just guessing now, but maybe this is what you are looking for:
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.