Monday 1 December 2014

How to update table with data from another table in Oracle?





Here is a sample code ...

UPDATE customers
SET    c_details = (SELECT contract_date
                    FROM   suppliers
                    WHERE  suppliers.supplier_name = customers.customer_name)
WHERE  customer_id < 1000; 


here customers,suppliers  are my table 


here I am going to update c_details in customers table with  contract_date in 
suppliers table with the condition suppliers.supplier_name = customers.customer_name.   

 and customer_id is less then 1000 .



No comments:

Post a Comment