Knowledgebase

MySql INNER JOIN

Posted by raulgonzalez, 09-19-2007, 05:10 PM
Hello all, I am trying to join to tables together to get results from each table. The structure looks like this: Table_1 --> Evaluation -------------------------------- |Evaluation_Date|Course|Instructor_ID|Instructor_Name|Answ1|Answ2|Answ3| Table_2 --> Student_info ------------------------------- |Student_Name|Course|Student_id|Done_already| I am trying to get the following in the HTML result |Evaluation Date|Course|Instructor_ID|Instructor_name|Answ1|Answ2|Answ3| So far it looks like I only need the first table, but I want to get only those records where Done_already = Yes which is in the second table. I tried the following and gave me a lot of records, might be repeated: $query = "SELECT students.ClassSection_id,students.Campus_id,students.InstructorName,students.id,evaluation.Course FROM students INNER JOIN (evaluation) ON (students.ClassSection_id=evaluation.Course) WHERE students.Done_Already = 'Yes'"; Then I added DISTINCT $query = "SELECT DISTINCT students.ClassSection_id,students.Campus_id,students.InstructorName,students.id,evaluation.Course FROM students INNER JOIN (evaluation) ON (students.ClassSection_id=evaluation.Course) WHERE students.Done_Already = 'Yes'"; and it returns the correct number of record count, but no records at all in the browser. Should I define the code below different or is my Query/Database all mest up? Please help: $EvaluationDate = $row['EvaluationDate']; $Course = $row['Course']; $Instructor_Name = $row['Instructor_Name']; $Answ1 = $row['Answ1']; $Answ2 = $row['Answ2']; $Answ3 = $row['Answ3']; I will go deeper into the MySql JOIN Manual. Thank you

Posted by justforselling1, 09-22-2007, 02:06 PM
The mysql is ok. I do think you are using the wrong function to get the results. mysql_fetch_array is your best bet while($row = mysql_fetch_array($result)) { echo $row["user_id"]; echo $row["fullname"]; }



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
Editing a DNS Zone (Views: 587)
Xen error (Views: 519)
Guess that server (Views: 638)
EditDNS down? (Views: 634)


Language:

Client Login

Email

Password

Remember Me

Search