1

Can someone help me with this sql statement to run on Oracle? I am new to Oracle. I tried different ways, but getting syntax error. With this statement I get Missing SET keyworkd error, if I remove employee, I get invalid column name for emp_id.

update emp_bonus, employee                                                               
set emp_bonus.bonus = '555'                        
where emp_bonus.emp_id = employee.emp_id and emp_bonus.bonus_id  = '101';

1 Answer 1

2

Yes, you have a syntax error. What do you like to do??

In this case the query would be constructed as follows:

UPDATE   EMP_BONUS
   SET   EMP_BONUS.BONUS = '555'
 WHERE   EMP_BONUS.BONUS_ID = '101'
         AND EXISTS (SELECT   'X'
                       FROM   EMPLOYEE
                      WHERE   EMP_BONUS.EMP_ID = EMPLOYEE.EMP_ID);

Where only update the BONUS field when the ID exists in the EMPLOYEE table.

Sign up to request clarification or add additional context in comments.

4 Comments

@user3613050 That's perfect. Anything just ask. Good luck.
Hi Fernando, what should be the command if I need to change the where clause to EMPLOYEE.RATE_ID = '133' instead of a column from other table (EMP_BONUS.BONUS_ID = '101')?
Never mind, adding that to the select statement took care of it.
@user3613050 Only will update more than one time, if any at EMP_BONUS table more than one record with the BONUS_ID = 101

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.