Skip to content
Worked Examples · Example 9.5

Q.The following query selects records of all the employees except Aaliya.

Tripura TbseTextbookSubjective· 2mImportance★★★★★
9% · 9/95 Questions
🔒 Locked · start free trial →

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 →

NOT Ename = 'Aaliya' (equivalently Ename != 'Aaliya') excludes exactly the one row for Aaliya from the chapter's own EMPLOYEE table (Table 9.8), returning all 9 remaining employees.

The query

SELECT *
FROM EMPLOYEE
WHERE NOT Ename = 'Aaliya';

WHERE filters rows; NOT negates the condition that follows it. So the query keeps every row except the one where Ename equals 'Aaliya'. This is equivalent to writing WHERE Ename != 'Aaliya' or WHERE Ename <> 'Aaliya'.

Running it against Table 9.8

EMPLOYEE has 10 rows; exactly one of them, EmpNo 101, is named Aaliya. Removing that one row leaves nine:

+-------+----------+--------+-------+--------+
| EmpNo | Ename    | Salary | Bonus | DeptId |
+-------+----------+--------+-------+--------+
|   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    | …

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.