Austin Hunter Austin Hunter - 1 month ago 10
MySQL Question

SQL cross referencing another table to check data

I have two tables:

student table --> This is student table

grades table --> This is grades table

What I am trying to do is get the first name and last name of the student who is eligible to take a class who has a grade equal or greater than a 'C' in a course.

How can I achieve this using a sql query?
So far, all I have is:

SELECT firstname, lastname, tnumber FROM students


I am unsure how to check if the student's grade in a courseid.

Thanks.

Example table inside of grades:

enter image description here

Answer

The code you need is:

SELECT students.firstname, students.lastname, students.tnumber, grades.tnumber FROM students, grades WHERE grades.tnumber=students.tnumber AND (grades.Grade='A' OR grades.Grade='B' OR grades.Grade='C')