Find record which does not have corresponding record x

mike6271

Registered User.
Local time
Today, 12:15
Joined
Sep 23, 2008
Messages
20
Hi

I am having real difficulty here. I have tblStudents (StudentID, Name etc.) and jtblStudentSession (SessionID, StudentID). Can someone please advise how I would query which Students are not registered for Session x. The unmatched records part is simple, what I cant work out is if how to find students registered for some sessions but not this one.

Thank you

Mike
 
Try the unmatched query wizard, then add a criteria on that field.
 
Hi

Thanks for replying

I don't know if I'm making myself clear. I have created the following query.

SELECT tblStudents.*
FROM tblStudents LEFT JOIN jtblStudentSession ON tblStudents.[fldStudentID] = jtblStudentSession.[fldStudentID]
WHERE (((jtblStudentSession.fldStudentID) Is Null Or (jtblStudentSession.fldSessionID)<>3));

However the bold section is meaningless because all students have some record.

I cant think of the criteria which would allow me to select all students who don't have a this particular sessionID but do have others.
 
You were clear, but upon reflection I'm not sure my answer would work. I think the session would have to be part of the join, not in the criteria. Here's a better idea I think: create a query that returns all the students who have taken session 3, then use the unmatched query wizard to compare the student table against that query, which would give you anyone who hasn't taken session 3. That would be more dynamic, as you could get the session number from user input.
 
Thanks Paul you are a genius.

This was actually the data source of my form listbox so you can multiselect students and the added students would jump to another listbox of added students.

You have saved me from a suicide pact with my computer.

Thanks a mill:):):)
 
No problemo! LOL at the suicide pact. Fake it out. Tell it to jump out the window first, and you'll be right behind it. They fall for that every time.
 

Users who are viewing this thread

Back
Top Bottom