WHERE clause with NULL and NOT NULL values

suggest change
SELECT Id, FName, LName, PhoneNumber, ManagerId, DepartmentId
FROM Employees
WHERE ManagerId IS NULL

This statement will return all Employee records where the value of the ManagerId column is NULL.

The result will be:

Id    FName    LName    PhoneNumber    ManagerId    DepartmentId
1     James    Smith    1234567890     NULL         1
SELECT Id, FName, LName, PhoneNumber, ManagerId, DepartmentId
FROM Employees
WHERE ManagerId IS NOT NULL

This statement will return all Employee records where the value of the ManagerId is not NULL.

The result will be:

Id    FName       LName     PhoneNumber    ManagerId    DepartmentId
2     John        Johnson   2468101214     1            1
3     Michael     Williams  1357911131     1            2
4     Johnathon   Smith     1212121212     2            1

Note: WHERE ManagerId = NULL and WHERE ManagerId <> NULL are never true. WHERE rejects those rows.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents