Alright.. i have this situation where I need to get data from 2 joined tables, where value X is present in column A on table2 but value Z is not present in column A on table2..
Basically here's the relevant info...
Table STUDENT:
primary_id
student_name
student_age
student_gradyear
Table TESTS:
primary_id
test_name
test_grade
The query thus far is:
Now I want to be able to select only those students who have the value of 'Test One' stored in the 'test_name' table with a test_grade value of 'A', but there is no value of 'Test Two' stored in the test_name column for that student.
I'm sure WHERE EXISTS and NOT EXISTS subqueries would be used.. but i'm just glitching out this morning and can't wrap my head around it.
Of course I could always just run two independent queries and then use a script to compare the results, but I much rather just have mysql do it in one fell swoop
Basically here's the relevant info...
Table STUDENT:
primary_id
student_name
student_age
student_gradyear
Table TESTS:
primary_id
test_name
test_grade
The query thus far is:
Code:
Select s.student_name, s.student_age, s.student_gradyear, t.test_name, t.test_grade
FROM STUDENT as s
INNER JOIN TESTS AS t ON (s.primary_id = t.primary_id)
(insert 'WHERE' clause here)
ORDER BY s.student_name;
Now I want to be able to select only those students who have the value of 'Test One' stored in the 'test_name' table with a test_grade value of 'A', but there is no value of 'Test Two' stored in the test_name column for that student.
I'm sure WHERE EXISTS and NOT EXISTS subqueries would be used.. but i'm just glitching out this morning and can't wrap my head around it.
Of course I could always just run two independent queries and then use a script to compare the results, but I much rather just have mysql do it in one fell swoop
Last edited: