Q.What does NULL represent in a database? Explain why 'Salary = NULL' does not work, and give the correct way to find rows with a missing salary.
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →A NULL represents a value that is missing, unknown or not applicable — for example, an employee whose salary has not yet been fixed. It is important to note that NULL is not the same as zero (a definite number) and not the same as an empty string '' (definite blank text); NULL means 'no value at all'.
Because NULL means 'unknown', any ordinary comparison with NULL gives the result 'unknown', which is neither true nor false. So a condition like Salary = NULL (or Salary <> NULL) is never satisfied, and such a row is never returned. This is why we cannot use = to look for missing values.
MySQL provides special tests for this purpose: IS NULL (true when the value is missing) and IS NOT NULL (true when it is present). To find employees whose salary is missing:
SELECT Name FROM Employee
WHERE Salary IS NULL;
``` …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.