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 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...

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

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

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 即可,不用那么复杂吧.

没有描述具体: 1、数据从一表插入到另一表。 insert into 新表 select * from 旧表 where 条件 = ?? 2、触发器,更新旧表时自动更新新表。 3、更新旧表。 update 新表 n set column_name = (select o.column_name from 旧表 o where o.id = n...

update 表1 set balance=balance+amount from 表2 where 表2.cardnumber='111111' and 表2.cardclose= '111111' and 表2.estate='可充值' and 表1.account='1111111111111111111' and 表1.estate='正常' 按你的写法,表2条件不成立,子查询取出...

这个是sqlservr写法,你啥数据库吧? update 表2 set 表2.f=表1.c from 表1 inner join 表2 on 表1.b=表2.e 你看看是不是用on后边那俩字段关联,不是的话你个换成表1.a=表2.d

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....

试试这个 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(...

网站地图

All rights reserved Powered by www.5213.net

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