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

首頁 > 數據庫 > MySQL > 正文

mysql多表join時候update更新數據的方法

2024-07-24 13:03:22
字體:
來源:轉載
供稿:網友
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.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 昌黎县| 孟村| 韩城市| 普定县| 于都县| 什邡市| 平武县| 修武县| 芜湖市| 故城县| 若羌县| 聂荣县| 响水县| 格尔木市| 隆昌县| 昌黎县| 平江县| 尖扎县| 尚志市| 盘锦市| 资源县| 隆林| 五原县| 手游| 塘沽区| 德阳市| 鄂伦春自治旗| 巧家县| 石门县| 大化| 宁安市| 武定县| 兴和县| 南昌市| 锦州市| 贞丰县| 临西县| 彰化县| 夏河县| 斗六市| 恩平市|