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.

本文mysql多表join时候update更新数据的方法到此结束。不要像玻璃那样脆弱。有的人眼睛总盯着自我,所以长不高看不远;总是喜欢怨天尤人,也使别人无比厌烦。没有苦中苦,哪来甜中甜?不要像玻璃那样脆弱,而应像水晶一样透明,太阳一样辉煌,腊梅一样坚强。小编再次感谢大家对我们的支持!

您可能有感兴趣的文章
MySQL左联多表查询where条件写法示例

mysql中多表删除其中ID相同记录的方法

mysql单表查询及多表查询命令详解

MySQL基础之多表查询案例分享

centos7安装MySQL教程