1. 程式人生 > >SQL從一個表查詢資料更新到另外一個表

SQL從一個表查詢資料更新到另外一個表

1、更新1個欄位

update ElectricMeterTemp a set fydlbid=(select fid from CT_EXP_ElectricityType b where a.fydlbname=b.cfname)
2、從a表查詢資料插入到b表
insert into ElectricMeter(fid,fnumber,cfaddress,CFElectricityTypeI,Cfrate,Cfenable,Cfmemo,Cfshareelecmeter)
 select t.fid,t.fnumber,t.faddress,t.fydlbid,t.frate,t.fenable,t.fmemo,t.fshare from ElectricMeterTemp t