mysql 连表更新数据_mysql多表join时候update更新数据的方法

sql语句:

update item i,resource_library r,resource_review_link l set i.name=CONCAT('Review:',r.resource_name) where i.item_id=l.instance_id

and l.level='item' and r.resource_id=l.resource_id and i.name=''

JOIN UPDATE & JOIN DELETE

update a

set a.schoolname = b.schoolname

from tb_Std as a join tb_Sch as b on a.School = b.School

where a.std_year = 2005

go

/*

(2 row(s) affected)

*/

select *

from tb_Std as a join tb_Sch as b on a.School = b.School

/*

A School A A School

2 2005 A A School A A School

3 2004 C A School C C School

4 2005 D D School D D School

(4 row(s) affected)

*/

delete a

from table1 a,table2 b

where a.col1 = b.col1

and a.col2 = b.col2

The above sql statement runs fine in sql Server.

If the Oracle 9i has different Syntax or if there is any other way to accomplish this with a single delete statement that would be really helpful.

> Hi,

>

> Is the following delete statement possible in Oracle 9i.

>

> delete a

> from table1 a,table2 b

> where a.col1 = b.col1

> and a.col2 = b.col2

>

> The above sql statement runs fine in sql Server.

>

> If the Oracle 9i has different Syntax or if there is any other way to accomplish this with a single delete statement that would be really helpful.

>

> Thanx in advance.

>

> -Bheem

Bheem,

Try this:

DELETE FROM table1 a where exists (select 1 from table2 b

where a.col1 = b.col1 and a.col2 = b.col2);

Hope this helps,

Tom K.

总结

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。

如您喜欢交流学习经验,点击链接加入交流1群:1065694478(已满)交流2群:163560250

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值