Using Null
-
List the teachers who have NULL for their department.
Why we cannot use =
You might think that the phrase dept=NULL would work here but it doesn't - you can use the phrase
dept IS NULL
That's not a proper explanation.
select name from teacher where dept is null
-
Note the INNER JOIN misses the teachers with no department and the departments with no teacher.
SELECT teacher.name, dept.name FROM teacher INNER JOIN dept ON (teacher.dept=dept.id)
-
Use a different JOIN so that all teachers are listed.
select teacher.name , dept.name from teacher left join dept on teacher.de