两表(多表)关联update的写法
因为数据库中有一些操作要做,是关于两个表之间关系的更新。但是报表写的不正确,老报错,我就慌了(怕不能及时完成操作)查了一下。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
)
0条评论