husslela03 Posted April 14, 2010 Share Posted April 14, 2010 Hello: I am having a problem with my mySQL query statement I will post the table structure below, and the statement i have now, and what i want to obtain: 1) What I want to do is get the assignment names from the assignment table that are related to the course name in the "courses" table and list all the assignments. I keep getting an error stating: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in on line 40 and I know that I get this error because the query is NOT returning anything. Here is the statement I was using and before that I also tried RIGHT JOIN and LEFT JOIN, but still am receiving the same error. $sql=mysql_query("SELECT * FROM courses, assignments FULL JOIN assignments ON courses.courseID=assignments.courseID"); here is the code that i am putting it in for my php statements: while($row = mysql_fetch_array($sql)) { echo $username. ' ' .$row['assignmentName']. '<br />'; } Here is my table structures 'courses' table courseID courseName 1 English 2 Math 3 Science 4 Psychology 'assignments' table: assignmentID courseID assignmentName assignmentMaxValue assignmentWeight 1 1 Homework1 100 10 2 1 Homework2 100 10 3 1 Quiz1 50 10 Any help would be greatly appreaciated! Quote Link to comment https://forums.phpfreaks.com/topic/198577-problem-with-mysql-query-statement/ Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 Try this - $sql=mysql_query("SELECT * FROM courses LEFT JOIN assignments ON (courses.courseID = assignments.courseID)"); Quote Link to comment https://forums.phpfreaks.com/topic/198577-problem-with-mysql-query-statement/#findComment-1042086 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.