Home > database >  Help: how to use the table A row data update table B A row data
Help: how to use the table A row data update table B A row data

Time:09-30

For example there are three rows of data in table A:

There are 2 rows of data in table B:

Now how to use the line 2 in table A data update line 1 in table B, other data unchanged line

CodePudding user response:

- about this
The update B
B.B set (b.X M, H)=(select A.X M, a. H from A where Anderson, D=B.I D)
Where the exists (select * from A where Anderson, D=B.I D)

CodePudding user response:


 UPDATE BSET (XH, XM)=(//the other fields to omit 
The SELECT XH, XM
FROM A
WHERE ID=40049 a
)
WHERE ID=5 ec18c

CodePudding user response:

refer to the second floor qq_38206656 response:
 
UPDATE BSET (XH, XM)=(//the other fields to omit
The SELECT XH, XM
FROM A
WHERE ID='40049 a'
)
WHERE ID='5 ec18c'

Forget the quotes

CodePudding user response:

I tried this is feasible,
 
The UPDATE B1 B
SET (B1. XH, B1. XM, B1, BH, B1. The MC, B1. XZ, B1, FS, B1, ZF)=
(SELECT A1. XH A1. XM, A1. BH, A1. MC, A1. XZ, A1, FS, A1. The government FROM A A1 WHERE B1. The ID=A1. ID)
WHERE B1. ID=
(SELECT A2. IDFROM A A2 WHERE B1. The DEPTNO=A2, DEPTNO)
  • Related