国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > MySQL > 正文

mysql多表join時(shí)候update更新數(shù)據(jù)的方法

2020-01-19 00:10:04
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
sql語(yǔ)句:
復(fù)制代碼 代碼如下:

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
復(fù)制代碼 代碼如下:

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)
*/

復(fù)制代碼 代碼如下:

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.
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 太仓市| 昌吉市| 于田县| 广平县| 江口县| 泾阳县| 达拉特旗| 读书| 黄冈市| 越西县| 宁陕县| 隆德县| 郎溪县| 舞阳县| 柘城县| 闽侯县| 白水县| 泰和县| 万荣县| 禄丰县| 诸暨市| 什邡市| 台湾省| 阜南县| 阿坝县| 青田县| 诏安县| 公安县| 云浮市| 龙州县| 汨罗市| 河源市| 宜春市| 库车县| 洛隆县| 依兰县| 什邡市| 革吉县| 镇原县| 米泉市| 商南县|