husslela03 Posted April 16, 2010 Share Posted April 16, 2010 i'm having trouble returning a result for mySQL statement i have: $sql2=mysql_query("SELECT * FROM assignments, courses LEFT JOIN assignments ON (courses.courseID = assignments.courseID) LEFT JOIN grades ON (assignments.assignmentID = grades.assignmentID) WHERE (grades.userID='$userID' AND assignments.courseID='$courseName')"); I want to find all the grades in the grades table partaining to the student and the class chosen Here are my table structures Courses table: courseID courseName 1 Class A 2 Class B Assignments table: assignmentID courseID assignmentName assignmentMaxValue assignmentWeight 1 1 Homework1 100 10 2 1 Homework2 100 10 Grades table gradeID userID assignmentID score 1 1 3 96 2 2 3 85 The userID for the student is carried in the session along with the courseID Any help would be appreciated with my mySQL statement So i want to find all the grades for the student for the matching courseID. Quote Link to comment https://forums.phpfreaks.com/topic/198708-help-with-mysql-statement/ Share on other sites More sharing options...
andrewgauger Posted April 16, 2010 Share Posted April 16, 2010 I think this is your problem: courseID='$courseName' courseName=$courseName and: remove the assignment after FROM: $sql2=mysql_query("SELECT grades.* FROM courses LEFT JOIN assignments USING (courseID) LEFT JOIN grades ON (assignments.assignmentID = grades.assignmentID) WHERE (grades.userID='$userID' AND assignments.courseName='$courseName')"); Unless $courseName was set to the course id. Quote Link to comment https://forums.phpfreaks.com/topic/198708-help-with-mysql-statement/#findComment-1042812 Share on other sites More sharing options...
husslela03 Posted April 16, 2010 Author Share Posted April 16, 2010 it worked! thank you so much! i might need you again shortly though! Quote Link to comment https://forums.phpfreaks.com/topic/198708-help-with-mysql-statement/#findComment-1042820 Share on other sites More sharing options...
andrewgauger Posted April 16, 2010 Share Posted April 16, 2010 Please post additional questions to the general forum unless they directly relate to this query, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/198708-help-with-mysql-statement/#findComment-1042821 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.