How do you find employees without a manager?
Solution
SELECT * FROM employees WHERE manager_id IS NULL;
Use IS NULL, not = NULL.
Think before looking at the solution
- What would the SQL query do?
- Which rows will match?
- Which columns will appear?
- What happens when NULL values are involved?
- Can the query be improved using an index?
