Worked Examples · Example 5
Q.Write SQL statements to
(i) give every employee in the 'IT' department a 10% increase in salary, and
(ii) delete the record of the employee whose EmpNo is 106.
ChseodishaTextbookSubjectiveImportance★★★★★est
50% · 8/16 Questions
✓ Free question
Both are DML operations and both use a WHERE clause so that they affect only the intended rows.
(i) A 10% increase means the new salary is the old salary multiplied by 1.10. We use UPDATE ... SET, with the calculation using the current Salary, restricted to the IT department:
UPDATE Employee
SET Salary = Salary * 1.10
WHERE Dept = 'IT';
(For an employee whose salary is NULL, the calculation gives NULL, so an unfixed salary stays unfixed — which is correct.)
(ii) To remove a single record we use DELETE FROM ... WHERE, matching the primary key:
DELETE FROM Employee
WHERE EmpNo = 106;
In both statements the WHERE clause is essential: without it, the UPDATE would raise every employee's salary and the DELETE would empty the whole table.
✓Final answer
UPDATE Employee
SET Salary = Salary * 1.10
WHERE Dept = 'IT';
DELETE FROM Employee
WHERE EmpNo = 106;
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.