Ask Your Question
3

Can Hive update or substitute all the values in rows of a table that match the values in another table?

asked 2023-05-27 04:34:30 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-05-27 04:49:02 +0000

djk gravatar image

Yes, Hive can update or substitute all the values in rows of a table that match the values in another table, using the JOIN clause. This allows for updating or replacing values in one table based on the values in another table. For example, the following query updates the values in the "sales" table based on matching values in the "new_sales" table:

UPDATE sales 
SET sales_amount = new_sales_amount
FROM sales 
JOIN new_sales 
ON sales.product_id = new_sales.product_id;

This query updates the "salesamount" column in the "sales" table with the corresponding values from the "newsalesamount" column in the "newsales" table, based on matching values in the "product_id" column.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-27 04:34:30 +0000

Seen: 3 times

Last updated: May 27 '23