简体   繁体   中英

Compare two tables and update one table in Oracle-sql

I have two tables in oracle database 'test_DB' as tmp_book and author as follows

在此处输入图像描述

tmp_book table has a smaller set. I need to compare these 2 tables as follows: get the first 'book_id' in tmp_book table and in author search for that 'book_id' and update column 'is_available_image_url' with value 'Y'.

This way I need to do this for all the records in the tmp_book table

Please help me with this.

This is an update with some filtering:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM