sql - How can I combine 2 joins in an update? -


the code below (currently error) update rows in table, i'm aiming code should update p.hour of per_id in clause , not rows.

it's important value set column form table worker , 1 table department

update worker set p_hour = p_hour + a.hour exists (select p.per_id, p.p_hour worker p, department p.per_id = a.per_id , p.per_id = '1234') 

this current error:

error @ line 2: ora-00904: "a.hour": invalid identifier

the canonical way in oracle is:

update worker w     set p_hour = (p_hour +                   (select d.hour                    department d                    w.per_id = d.per_id                   )                  )     w.per_id = '1234' ,           exists (select 1                   department d                   w.per_id = d.per_id                  ); 

you can use merge.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -