mysql join 4 tables

hi there im having trouble getting the fourth table added to my sql query code below:-
[php]$qry = mysql_query(“SELECT Result.resultID, Test.testName,User.userName,Class.className
from test inner join
(result inner join user
on result.userID=user.userID)
on test.testID=result.testID
where flag =‘yes’;”);[/php]
the code works for three tables but i cant seem to get the fourth table aswell the class needs to be joined by the user id of the results table

[php]

$qry = “SELECT DISTINCT User.userName, Result.resultID, Test.testName, Class.className
FROM User, Result,Test,Class
WHERE Result.userID = User.userID AND Result.testID = Test.testID AND Test.className = Class.className AND flag = ‘yes’ AND teacherID=’$_SESSION[SESS_MEMBER_ID]’ ORDER BY Test.testID”;

[/php]

not to worry worked it out

Sponsor our Newsletter | Privacy Policy | Terms of Service