I am trying to update
all rows where the salary is less than the average of all salaries in the table.
UPDATE PostOfficeStaff
SET salary = salary * 1.05
WHERE officeNo = 1
AND salary < (SELECT AVG(salary) FROM PostOfficeStaff)
It is giving me an error saying
You can't specify target table 'PostOfficeStaff' for update in FROM clause
I have tried this query without the FROM PostOfficeStaff
as well and while it doesn't give me an error, it also does nothing.
How can I do this?