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
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
