www.5213.net > SQL2005跨表upDAtE的问题

SQL2005跨表upDAtE的问题

update a set a.c=b.d from aa a, bb b where a.a = b.b 或者 update aa set c = (select top 1 d from bb where aa.a=bb.b)

update a set a.pic=b.pic where a.title=b.title 即可,不用那么复杂吧. 不好意思,漏写了from语句,完整的写法是: update a set a.pic=b.pic from a,b where a.title=b.title 即可,不用那么复杂吧.

试试这个 update 表名 a set a.vin_code = (select b.vin_code from (select vin_code_s,vin_code from 表名 where id in (select max(id) from 表名 group by vin_code_s)) b where a.vin_code_s=b.vin_code_s) where a.id not in (select max(...

update A set A.shl = A.shl - B.shl from retmxls A,daysphz B where A.spid = B.spid and A.fdbs = B.fdbs and A.rq = B.rq and A.ontime > '17:37:18' and A.shky = '002' and A.fdbs = 'HKD' 这个是SqlServer的语法

UPDATE bSET b.Com_introduce = a.company_intro --这里改改FROM australia.dbo.companytest as a, yimingong.dbo.company as b WHERE(a.id = 2 AND b.Com_Id = 1) OR(a.id = 14 AND b.Com_Id = 2) OR(a.id = 18 AND b.Com_Id = 3) OR(a.id = 5 ...

一条Update更新语句是不能更新多张表的,除非使用触发器隐含更新。而表的更新操作中,在很多情况下需要在表达式中引用要更新的表以外的数据。我们先来讨论根据其他表数据更新你要更新的表 一、MS SQL Server 多表关联更新 sql server提供了updat...

用别名 update a set a.unitname=data_upload.unitname from servera.flgl_db_210500.dbo.data_upload_1 AS a,Data_Upload where Data_Upload.industry_type= a.industry_type

UPDATE T SET T.foutquantity = ISNULL(a.a, 0) FROM SO_SODetails T LEFT OUTER JOIN (SELECT SUM(fOutQuantity) AS a, iSOsID AS b FROM DispatchLists WHERE (iSOsID IS NOT NULL) GROUP BY iSOsID) AS a ON T.iSOsID = a.b WHERE (ISNULL(a....

--要求两个表字段名都相同--根据表1字段,拼一个update的sql语句,然后执行Declare @SQL Varchar(1000)='Update 表1 Set 'Select @SQL=@SQL+'表1.'+name+'=表2.'+name+',' from sys.columns where object_id=object_id('表1')and name'id'Set @SQL...

更新查询,不同的数据库之间的语法差别一般都比较大。 下面按MSSQL修改如下: update TF_PSS_Z set TF_PSS_Z.BC=b.Qty-a.Qty from TF_PSS a,TF_CK b ,TF_PSS_Zwhere a.PRD_NO=b.PRD_NO and a.PS_NO=TF_PSS_Z.PS_NO;ACCESS或MySQL可以简化一些: ...

网站地图

All rights reserved Powered by www.5213.net

copyright ©right 2010-2021。
www.5213.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com