Changes

Inserting Data into a MySQL Database

850 bytes added, 19:16, 3 October 2007
Reducing the INSERT Performance Load
);
</pre>
 
== Inserting Results from a SELECT Statement ==
 
A particularly useful SQL statement involves combining the INPUT and SELECT statements. In this scenario, the SELECT statement reads the values (typically from anotehr table) to be added to the current table. This approach is known as ''INSERT SELECT''. and can be used to perform tasks such as added all the rows from one table to another table with the same column layout. The following example uses a ''SELECT'' statement to retrieve the rows in a table called ''old_products'' and adds them to a table called ''new_products'':
 
<pre>
INSERT INTO new_products
( product_id,
product_name,
product_description,
product_location,
product_quantity
)
SELECT product_id,
product_name,
product_description,
product_location,
product_quantity
FROM old_products;
== Reducing the INSERT Performance Load ==