多关联update的SQL语句

[b][color=red]MYSQL[/color][/b]: [url]http://www.111cn.net/database/mysql/45963.htm[/url]
1. update table_1 set score = score + 5 where uid in (select uid from table_2 where sid = 10);
===>等价于===>
update table_1 t1 inner join table_2 t2 on t1.uid = t2.uid set score = score + 5 where t2.sid = 10;

2.
UPDATE Track
INNER JOIN MV
ON Track.trkid=MV.mvid
SET Track.is_show=MV.is_show
WHERE trkid<6

等同于

UPDATE Track,MV
SET Track.is_show=MV.is_show
WHERE Track.trkid=MV.mvid and trkid<6

更多条件
update PSI_WAREHOUSE_IO_RECORD t1 
inner join PSI_SUPPLY_ORDER_DETAIL t2 on t1.P_ORDER_DETAIL_ID = t2.ORDER_DETAIL_ID
inner join PSI_SUPPLY_GOOD t3 on t2.SUPPLY_GOOD_ID = t3.SUPPLY_GOOD_ID
set t1.GOOD_ID = t3.GOOD_ID, t1.P_ORDER_ID = t2.SUPPLY_ORDER_ID, t1.SUPPLY_ID = t2.SUPPLY_ID WHERE t1.IO_TYPE='SUPPLY';



[color=red][b]ORACLE[/b][/color] 多表关联 UPDATE 语句 [url]http://it.oyksoft.com/post/641/[/url]


[color=red]postgres[/color] 多表查询更新 [url]http://liubl2011.iteye.com/blog/1985562[/url]
更新一张表a的内容关联其他表作为条件:
Sql代码 收藏代码
update a set name='xx'
from t1 t1,t2 t2
where t1.age=t2.age
t1.name = a.name


第二种比较小白我以前的做法
Sql代码 收藏代码
update tc set task_code = 'xxxx'
WHERE
task_code = 'xxxxx2'
AND exists (
select cust_code FROM alc
WHERE district_code = 'aa'
AND cust_code = tc.cust_code
AND cust_sample_flag = '1'
)
[color=red][b]sql server[/b][/color]多表关联update
UPDATE Tab1 SET a.Name = b.Name FROM Tab1 a,Tab2 b WHERE a.ID = b.ID
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值