How the value of the data table B, update Table A

If there is table

A: int id

  int B_id

  int C_id

 

B: int id

 int C_id

 

C_id is a redundant field, you want the data in Table A, B with the same table, Sql statement is as follows:

 

update Report A set C_id= ( select C_id from B where B.id = A.B_id)

Guess you like

Origin www.cnblogs.com/everydaygift/p/10955829.html