How to fill empty column from another table in oracle?

Member

by brandy , in category: Third Party Scripts , 2 months ago

How to fill empty column from another table in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by daisha , 2 months ago

@brandy 

You can fill an empty column in one table with data from another table in Oracle by using an UPDATE statement with a subquery.


Here's an example:

1
2
3
4
5
6
UPDATE table1 t1
SET t1.column_to_fill = (
    SELECT column_with_data_to_fill
    FROM table2 t2
    WHERE t1.join_column = t2.join_column
);


In this example, table1 is the table with the empty column that you want to fill, table2 is the table with the data to fill the empty column, column_to_fill is the empty column in table1, and column_with_data_to_fill is the column in table2 that contains the data you want to fill the empty column with. join_column is the column that is used to match rows between the two tables.


Make sure to replace table1, table2, column_to_fill, column_with_data_to_fill, and join_column with the actual table and column names in your database.