What I want to achieve is a single query to update those two values. If possible.
I have a table named employee , with 3 columns that are salary ,city and employees
I already completed what was needed to be done,
What I needed to do was :
city | salary | employees |
---|---|---|
city1 | 650 | employee1 |
cit2 | 700 | employee2 |
my two separate query are:
#1
UPDATE employee
SET salary= salary+ (salary* 15 / 100)
WHERE city= 'city1' AND salary<=800;
#2
UPDATE employee
SET salary= salary+ (salary* 18 / 100)
WHERE city= 'city2' AND salary<=800;;
You can use a case
expression:
UPDATE employee
SET salary = salary * (1 + CASE WHEN city = 'city1' THEN 15 ELSE 18 END) / 100
WHERE city IN ('city1', 'city2') AND salary <= 800;