我是 oracle 的新手,我的其中一个 SQL 查询有问题。
有 2 个用户:User1
和 User2
:
Tab1 Tab2 -------- -------- EmpNo EmpNo EmpName EmpName ContactNo Salary Location
User2 has all privileges in User1.Tab1, and there is no foreign key relationship between the two tables.
The Problem:
I wanted to add a column in tab2 "NameDesignation
" And I wanted to insert the value in this column after checking the following condition:
WHEN User1.Tab1.EmpNo = User2.Tab2.EmpNo THEN
INSERT INTO Tab2 VALUES (&designation)
我真的不知道该怎么做,希望能得到一点帮助。有什么想法吗?
最佳答案
尝试这个:
update user2.tab2.empno t2
set NameDesignation= &designation
where exists (select ''
from user1.tab1 t1
where t1.empno=t2.empno)
(声明更新以匹配编辑的问题)
关于oracle - 如何在 Oracle 中实现条件更新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/585090/