Difference between revisions of "Oracle/Update join"
Jump to navigation
Jump to search
| Line 6: | Line 6: | ||
SET t.bonus = 0.1 * t.salary; | SET t.bonus = 0.1 * t.salary; | ||
</source> | </source> | ||
Views and selects with joins may only be updated when each row can be identified by a uique ID, so the join MUST be performed using key columns (in this example emloyee_id)! | |||
[[Category:Oracle]] | [[Category:Oracle]] | ||
Revision as of 09:45, 7 December 2009
UPDATE (SELECT b.bonus, e.salary
FROM employee_bonus b
JOIN employees e ON b.employee_id = e.employee_id
WHERE e.bonus_eligible = 1) t
SET t.bonus = 0.1 * t.salary;
Views and selects with joins may only be updated when each row can be identified by a uique ID, so the join MUST be performed using key columns (in this example emloyee_id)!