两表(多表)关联update的写法

两表(多表)关联update的写法,第1张

两表(多表)关联update的写法,第2张

因为数据库中有一些操作要做,是关于两个表之间关系的更新。但是报表写的不正确,老报错,我就慌了(怕不能及时完成操作)查了一下。NND,原来SQL是在SQL Server下写成一种独特的形式。这个语法在Oracle下不行,我赶紧改回来,及时完成了任务。顺便也贴一下找到的SQL,有一天忘了,不如拿回来这里:

更新客户a
set city _ name =(select b . city _ name from tmp _ cust _ city b where b . customer _ id = a . customer _ id)
where exists(select 1
from tmp _ cust _ city b
where b . customer _ id = a . customer _ id
)

-更新超过2个值
更新客户a
集合(city _ name,customer _ type)=(select b . city _ name,b . customer _ type
from tmp _ cust _ city b
where b . customer _ id = a . customer _ id)
where exists(select 1
from tmp _ cust _ city b
where b . customer _ id = a . customer _ id
)

位律师回复
DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
白度搜_经验知识百科全书 » 两表(多表)关联update的写法

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情