注册 登录
编程论坛 SQL Server论坛

数据更新问题.(求助)

sky_yang_sky 发布于 2008-10-15 11:11, 1336 次点击
表t_icitem中有栏位fitemid,ferpclsid等栏位,表newtable中有fitemid,ferpclsid两个栏位,两表中fitemid是相同的,现要求当两表中fitemid相同,如果ferpclsid不同时,将t_icitem中的ferpclsid更新为表newtable中的值,应如何实现?如
表t_icitem
Ferpclsid fitemid……..
1        8941
1        8942
1        8943
2        8944
2        8946

表newtable
Ferpclsid fitemid
1        8941
3        8942
1        8943
3        8944
2        8946

更新后表t_icitem变为
Ferpclsid fitemid…….
1        8941
3        8942
1        8943
3        8944
2        8946
2 回复
#2
happynight2008-10-15 11:19
UPDATE t_icitem SET t_icitem.erpclsid=newtable.ferpclsid
FROM t_icitem INNER JOIN newtable ON t_icitem.fitemid=newtable.fitemid
AND t_icitem.erpclsid<>newtable.ferpclsid
#3
sky_yang_sky2008-10-28 16:20
谢谢
1