DJ_AM_Juicebox
asked on
Inner join with a where clause?
Hi,
I need to do a join with a where clause. Something like:
// students
id | name
// grades
id | student_id | value
SELECT student.id, student.name, grade.value FROM students WHERE student.id = 'abc' AS student INNER JOIN grades grade ON grade.student_id = student.id
Basically I want to select some fields from the students table, some fields from the grades table, where the student id = "abc",
Thanks
I need to do a join with a where clause. Something like:
// students
id | name
// grades
id | student_id | value
SELECT student.id, student.name, grade.value FROM students WHERE student.id = 'abc' AS student INNER JOIN grades grade ON grade.student_id = student.id
Basically I want to select some fields from the students table, some fields from the grades table, where the student id = "abc",
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
didnt you tried my post? It gives the same result as igni7e's post. You should accept my answer or split the points.
Same result, but my answer is better and cleaner.
SELECT student.id, student.name, grade.value
FROM students
INNER JOIN grades grade ON grade.student_id = student.id
WHERE student.id = 'abc'