Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select

Status
Not open for further replies.

cdg15

IS-IT--Management
Nov 28, 2005
6
GB
Hi

A simple one I'm sure.

How do I select all records from one table that do not have a FK in another.

EG
Table_Class
ClassID
ClassName
TeacherID

Table_Teacher
TeacherID
Name

I want to see a list of Teachers who are not assigned to a Class.

Thanks in advance

 
SELECT T.TeacherID, T.Name
FROM Table_Teacher T LEFT JOIN Table_Class C ON T.TeacherID = C.TeacherID
WHERE C.ClassID Is Null

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV, Great!

I was using = 0

Thank You
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top