国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 历史| 旺苍县| 汤阴县| 拜城县| 乳山市| 全州县| 黄梅县| 肥东县| 疏勒县| 全南县| 冷水江市| 东海县| 宾阳县| 贡觉县| 酒泉市| 通榆县| 修武县| 乳山市| 云阳县| 容城县| 五家渠市| 巧家县| 双峰县| 刚察县| 兴仁县| 丹东市| 金昌市| 铜山县| 沾益县| 疏附县| 天津市| 梁山县| 武穴市| 项城市| 彭州市| 卓资县| 云阳县| 沽源县| 汨罗市| 从江县| 襄垣县|