Oracle Update multi-table association

xiaoxiao2021-03-06  15

Update a.a3 = a.a3 b.b3 Problems: A1, A2, A3 Table B Structure: B1, B2, B3 where A1, B1 is PK, the cut value is the same, A1 = B1. How to implement the following features of the SQL statement or process is updated to update the A3 of the A table, with the sum update of A.A3 and B.B3.

3> Update a set A3 = (SELECT A.A3 B.B3 from b where a.a1 = b.b1);

7> Update (SELECT A1, A3, B1, B3 from A, B WHERE A1 = B1) SET A3 = A3 B3

Opening the implementation plan, talking about the efficiency is there is not too much meaningful ^ _ ^ .. The three floors and the result of the writings of the 7th floor are different. The writing of the third floor update all records, and only modify the 7th floor The relevant record information of the two. The reading of the 7th floor can easily control the execution plan of this UPDATE statement, but the request B table must have a primary key index on the corresponding field :), there is a primary key on the corresponding field on the corresponding field. When indexing, it is recommended to use the 7th floor. You can refer to this post ^ _ ^

http://www.cnoug.org/viewthread.php?tid=44070

(The test did not succeed .. I don't know how to do it.)

Refer to:

I admire. Holding the attitude of learning, renovating the third floor, there is no primary key, please advise: Update ASET A3 = (SELECT A3 B3 from B Where A1 = B1) WHERE A1 = (SELECT B1 from b where A1 = B1)

as follows:

Update con_eme_on20050309 a set a.con_price = (Select a.con_price (B.noJob-a.nojob) (B.Medicare-a.medicare) (B.BIRTHFEE-A. BIRTHFEE) (B.Bruisefee-a.bruisefee) from con_eme_on200404 b Where a.emp_cod = B.Emp_cod and a.if_act = '1' and a.emp_base! = B.Emp_base), a.emp_base = (Select B. EMP_BASE FROM CON_EME_ON200404 B Where a.emp_cod = b.emp_cod and a.if_act = '1' and a.emp_base! = b.emp_base), a.annuity = (Select B.annuity from con_eme_on200404 b where a.emp_cod = B. EMP_COD and A. IF_ACT = '1' and a.emp_base! = b.emp_base), A.NOJOB = (Select B.NOJOB FROM CON_EME_ON200404 B Where A.EMP_COD = B.EMP_COD AND A.IF_ACT = '1' and A .emp_base! = b.emp_base), A.Medicare = (Select B.Medicare from Con_EME_ON200404 B Where a.emp_cod = B.Emp_cod and a.if_act = '1' and a.emp_base! = B.EMP_BASE), A. birthfee = (select b.birthfee from con_eme_on200404 b where a.emp_cod = b.emp_cod and a.if_act = '1' and a.emp_base! = b.emp_base), a.bruisefee = (select b.bruisefee from con_eme_on200404 b where a.emp_cod = B.Emp_cod and a.if_act = '1' and a.emp_b ASE! = b.emp_base), a.nojobbase = (select B.NOBBASE FROM CON_EME_ON200404 B WHERE A.EMP_COD = B.EMP_COD and A.IF_ACT = '1' and a.emp_base! = b.emp_base), A.Mediabase = (select b.mediabase from con_eme_on200404 b where a.emp_cod = b.emp_cod and a.if_act = '1' and a.emp_base! = b.emp_base), a.birthbase = (select b.birthbase from con_eme_on200404 b where a .emp_cod = b.emp_cod and a.if_act = '1' and a.emp_base! = b.emp_base), A.BruiseBase = (SELECT B.BRUISEBASE FROM CON_EME_ON200404 B Where a.emp_cod =

B.emp_cod and a.if_act = '1' and a.emp_base! = b.emp_base) Where a.emp_cod in (SELECT B.EMP_COD FROM CON_EME_ON200404 B Where A.EMP_COD = B.EMP_COD and A.IF_ACT = '1' And a.emp_base! = B.EMP_BASE) Provident Fund:

update con_eme_on20050309 a set a.con_price = (select a.con_price (b.accumulation-a.accumulation) from con_eme_on200404 b where a.emp_cod = b.emp_cod and a.if_act = '1' and a.emp_base! = b.emp_base ), a.accumulation = (select b.accumulation from con_eme_on200404 b where a.emp_cod = b.emp_cod and a.if_act = '1' and a.emp_base! = b.emp_base), a.accumulationBase = (Select B.accumulationBase from con_eme_on200404 b where a.emp_cod = b.emp_cod and a.if_act = '1' and a.emp_base! = b.emp_base), a.accumulationbase1 = (select b.accumulationbase1 from con_eme_on200404 b where a.emp_cod = b.emp_cod And a.if_act = '1' and a.emp_base! = b.emp_base) where a.emp_cod in (select b.emp_cod from control, "device_on200404 b where a.emp_cod = b.emp_cod and a.if_act = '1' and A. EMP_BASE! = B.EMP_BASE)

转载请注明原文地址:https://www.9cbs.com/read-48935.html

New Post(0)