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

SQL2005跨表upDAtE的问题

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.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的语法

更新查询,不同的数据库之间的语法差别一般都比较大。 下面按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可以简化一些: ...

如果两个表有关联的话是可以的,比如A表的id和b表的b_id外键关系就可以 update a left join b on a.id = b.b_id set a.name = '',b.name='' (where条件)

UPDATE b SET 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.i...

CREATE TRIGGER trigger_cgjh_insert ON [dbo].[cg_cgjh_bt] FOR INSERT AS BEGIN insert into openrowset('sqloledb','192.168.0.100';'sa';'10060','select * from knss2009.dbo.yw_kck') select * from yw_kck END 给你写过例子可以实现跨服...

看表结构, 如果没有主键无法只锁定行如果要验证的话, 只需要类似下面的方法就行了: -- 开事务, 以保持锁BEGIN TRAN-- 更新update table a set column1 = 1 where idx = 1-- 列出锁信息EXEC sp_lock @@spid-- 提交或者回滚事务COMMIT/ROLLBACK TR...

试试这个 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 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 表1 set 赋值.... from 表1 关联 表2 on 表1与表2的关系 例如: 表:A,列:ID,val1,val2 表:B,列:ID,val3,val4 表A和表B是通过ID相互关联 1、想将表A中的val1,val2的值分别使用表B中的val3,val4代替,...

网站地图

All rights reserved Powered by www.5213.net

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