INSERT INTO SELECT
INSERT INTO SELECT is a SQL statement in the DML Statements category. Inserts rows from a SELECT query result into an existing table. The syntax is INSERT INTO target_table (columns) SELECT columns FROM source_table WHERE condition;. It returns rows inserted. A typical example: INSERT INTO archived_orders (id, customer_id, total) SELECT id, customer_id, total FROM orders WHERE order_date < '2025-01-01'; -- Archives old orders A close relative is INSERT INTO, which inserts new rows into a table. A close relative is UPDATE, which modifies existing rows in a table. Always use WHERE to avoid updating all rows. A close relative is DELETE, which removes rows from a table. Always use WHERE to avoid deleting all rows. More about this category: Data Manipulation Language — INSERT, UPDATE, DELETE, REPLACE, MERGE. Related DML Statements entries: INSERT INTO, UPDATE, DELETE, REPLACE INTO, INSERT ... ON DUPLICATE KEY UPDATE, MERGE, UPSERT (PostgreSQL), DELETE with JOIN.