1
My tables
EMPREGADO Cod_Emp, Nome_Emp
COMPANHIA Cod_Comp, Nome_Comp
TRABALHA Cod_Emp, Cod_Comp, Salário, Cod_Emp_Supervisor
I want to give a 10% increase to all company supervisors' test'.
UPDATE trabalha
INNER JOIN companhia ON trabalha.Cod_Comp = companhia.Cod_Comp AND companhia.Nome_comp = 'teste'
SET salario = salario + (salario*0.10)
WHERE Cod_Emp IN (SELECT Cod_Emp_Supervisor FROM trabalha)
I did it this way, but it’s not quite what I wanted. I was trying to check with the WHERE the Cod_emp with the Cod_emp_supervisor, so I would know that that employee is a supervisor. And then check the company that he works with JOIN.
– vdschuck
@vdschuck In the WORK table the supervisor type employee the Cod_emp_supervisor field is null or with the same code as the Cod_emp field?
– Thiagosilr
That’s why I put the clause on JOIN T.Cod_emp = T.Cod_emp_supervisor to obtain only the supervisors.
– Thiagosilr