oracle - 如何在 Oracle 中实现条件更新?

标签 oracle oracle10g

我是 oracle 的新手,我的其中一个 SQL 查询有问题。
有 2 个用户:User1User2 :

     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/

相关文章:

Oracle 触发器不起作用

java - 验证 oracle 的 java 源中的 xml 文档

java - 使用并行流提高数据库密集型任务的 CPU 利用率

java - 我可以在 Oracle 10g 数据库上使用 Oracle JDBC 12.1.0.1(用于 12c 数据库)吗?

java - Hibernate使用数据库触发器填充主键

plsql - PL-SQL递归函数

sql - 如何在 SQL (Oracle) 中随机排列数据?

database - ORA-12154 : TNS:could not resolve the connect identifier specified using TOAD client

oracle - 是否可以在存储过程中使用 "return"?

sql - 使用表达式按列表分区