r/DatabaseHelp • • Apr 14 '18
Retrieve data based on inequality
Hello Everyone, I'm sorry if the title wasn't clear enough
My question is: suppose we have the following tables
I'm using MS-ACCESS but any SQL flavor would suffice, How would I retrieve the PNAME, that weren't supplied by sname="jones"
Thank you in advance
1
Upvotes
View all comments
Show parent comment
2
u/stebrepar Apr 14 '18 edited Apr 14 '18
I think an approach that should work would be to do a full join on the student and subject tables, and left join that to the degree table on matching student IDs and subjects, and take the rows from that where the joined degree columns are null.
For example with students A and B and subjects 1 and 2, let the only degree be A,1. The full join of student and subject would give:
Then the left join with degree would give:
So selecting just where the nulls are would give the answer you're looking for. There's probably a better way, but that's all I've got right now.