Q.The following query selects details of all those employees who have not been given a bonus. This implies that the bonus column will be blank.
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 →"The bonus column is blank" means the column contains NULL. NULL is not zero and not an empty string — it is the absence of a value, and it can only be tested with the IS NULL operator:
SELECT * FROM EMPLOYEE WHERE Bonus IS NULL;
Concept understanding — what NULL really is
| Value in the column | Meaning | Test that finds it |
|---|---|---|
0 | a bonus of zero rupees was given | Bonus = 0 |
'' (empty string) | an empty text value was stored | Bonus = '' |
NULL | no bonus value exists at all — unknown / not applicable | Bonus IS NULL |
The three are genuinely different. An employee with Bonus = 0 was processed and awarded nothing; an employee with Bonus = NULL was never assigned a bonus at all. The question says the column is blank, which is the NULL case.
SQL uses three-valued logic: TRUE, FALSE and UNKNOWN. Any arithmetic or comparison involving NULL yields UNKNOWN, and a WHERE clause only keeps rows for which the condition is TRUE. So Bonus = NULL is UNKNOWN for every single row — including the NULL ones — and the query returns nothing at all. It is not an error; it silently returns an empty set, which is far more dangerous.
The real EMPLOYEE table (Table 9.8)
| EmpNo | Ename | Salary | Bonus | DeptId |
|---|---|---|---|---|
| 101 | Aaliya | 10000 | 234 | D02 |
| 102 | Kritika | 60000 | 123 | D01 |
| 103 | Shabbir | 45000 | 566 | D01 |
| 104 | Gurpreet | 19000 | 565 | D04 |
| 105 | Joseph | 34000 | 875 | D03 |
| 106 | Sanya | 48000 | 695 | D02 |
| 107 | Vergese | 15000 | NULL | D01 |
| 108 | Nachaobi | 29000 | NULL | D05 |
| 109 | Daribha | 42000 | NULL | D04 |
| 110 | Tanya | 50000 | 467 | D05 |
The query
mysql> SELECT * FROM EMPLOYEE
-> WHERE Bonus IS NULL;
Output
+-------+----------+--------+-------+--------+
| EmpNo | Ename | Salary | Bonus | DeptId |
+-------+----------+--------+-------+--------+
| 107 | Vergese | 15000 | NULL | D01 |
| 108 | Nachaobi | 29000 | NULL | D05 |
| 109 | Daribha | 42000 | NULL | D04 |
+-------+----------+--------+-------+--------+
3 rows in set (0.00 sec)
Row-by-row evaluation
| Employee | Bonus | Bonus IS NULL | Selected? |
|---|---|---|---|
| Aaliya | 234 | FALSE | no |
| Kritika | 123 | FALSE | no |
| Shabbir | 566 | FALSE | no |
| Gurpreet | 565 | FALSE | no |
| Joseph | 875 | FALSE | no |
| Sanya | 695 | FALSE | no |
| Vergese | NULL | TRUE | yes |
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.