SQL Insert statement with example

The insert statement uses the data returned from the subquery to insert into another table.

Example SQL Insert statement:

Input Table:

Products Table:

Orders Table:

Output Table:

Question: insert Product_id  P_name and sell_price from products in orders for product_id with sell price more than 1000.

SQL Command

insert into orders select Product_id, P_name, sell_price from products where Product_id in (select product_id from products where sell_price>1000);

Download input data for insert into

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Back to top button