【问题标题】:Compare two tables and update one table in Oracle-sql在Oracle-sql中比较两张表并更新一张表
【发布时间】:2020-05-12 12:48:36
【问题描述】:

我在 oracle 数据库'test_DB'中有两个表作为 tmp_book 和作者如下

tmp_book 表有一个较小的集合。 我需要比较这两个表如下: 获取 tmp_book 表中的第一个 'book_id' 并在 author 中搜索该 'book_id' 并使用值 'Y' 更新列 'is_available_image_url'。

这样我需要对tmp_book表中的所有记录都这样做

请帮帮我。

【问题讨论】:

    标签: sql oracle sql-update


    【解决方案1】:

    这是一个update,带有一些过滤功能:

    update author
        set is_available_image = 'Y'
        where exists (select 1 from tmp_book b where b.book_id = author.book_id);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-26
      • 2020-08-12
      • 2011-06-04
      • 1970-01-01
      • 1970-01-01
      • 2011-10-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多